#include
#include
#include
#include
#include
#include
#include
#include
void goback(void)
{
int i=0;
pid_t pid;
chdir("/");
pid=fork();
if (pid<0) {
perror("fork");
exit(1);
} else if (pid>0)
exit(0);
setsid();
syslog(LOG_INFO|LOG_LOCAL2,"%s,%d","The deamon is started!!!\n",getpid());
}
int main(void)
{
int ret;
int fd;
goback();
fd=open("/dev/console",O_RDWR|O_NOCTTY);
if(fd<0) {
perror("open console");
exit(1);
}
ret=write(fd,"\007\007\007\007",strlen("\007\007\007\007"));
if(ret<0) {
perror("write");
exit(1);
}
while(1)
sleep(1);
return 0;
}
阅读(1669) | 评论(0) | 转发(0) |