星期二, 8月 31, 2004

不能貼Code...會被切掉..因為Code有">" "<"符號?

int execed = 0;


int main(int argc, char *argv[])
{
char c;
int _argc = 0;
char *_argv[3];
pid_t pid;

while ((c=getopt(argc, argv, "D")) > 0) {
switch(c) {
case 'D':
execed = 1;
break;
default:
fprintf(stderr, "You probably don't want to pass "
"options to this\n");
exit(1);
}
}

if (!execed) {
if ((pid = vfork()) .lt. 0) {
fprintf(stderr, "vfork failed\n");
exit(1);
} else if (pid != 0) {
exit(0);
}

_argv[_argc++] = argv[0];
_argv[_argc++] = "-D";
_argv[_argc++] = NULL;
execv(_argv[0], _argv);
/* Not reached */
fprintf(stderr, "Couldn't exec\n");
_exit(1);

} else {
setsid();
chdir("/");
umask(0);
close(0);
close(1);
close(2);
}

for (;;) {
sleep(5);
syslog(LOG_INFO, "Still sleeping\n");
}
}


把"<"改成 .lt.後 OK.

沒有留言:

張貼留言