|
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <syslog.h>
- #include <fcntl.h>
- #define MAXLINE 1024
- int
- main(void)
- {
- int fd,n;
- char buf[MAXLINE] ;
- if((fd=open("/dev/klog",O_RDONLY))<0) {
- printf("open /dev/klong error\n");
- return(1);
- }
- while((n=read(fd,buf,MAXLINE))>0) {
- putc(n,STDOUT_FILENO);
- }
- if(n<0) {
- printf("read fd error\n");
- return(2);
- }
- close(fd);
- return(0);
- }
复制代码
最后的结果是code dump ??怎么读/dev/klog
system: FreeBSD 4.8 |
|