setsid();
if ((pid = fork())) {
exit(0);
} else if (pid < 0) {
exit(1);
}
chdir("/tmp");
umask(0);
return;
}
/* 运行系统命令 */
int run_system_cmd(const char *syscmd)
{
FILE *fp = NULL;
if (syscmd == NULL) {
return -1;
}
memset(buffer, 0, BUFFSIZE1);
snprintf(buffer, BUFFSIZE1, syscmd);
fp = popen(buffer, "r");
if (!fp) {
return 0;
}
memset(buffer, 0, BUFFSIZE1);
if (!fgets(buffer, BUFFSIZE1, fp)) {
pclose(fp);
return 0;
}
if (!strncasecmp(buffer, "", BUFFSIZE1)) {
pclose(fp);
return 0;
}
pclose(fp);
return 1;
}
int main(int argc, char *argv[])
{
int ret = 0;