linux下使用
采用sh的模式,会导致开机alt+f2无法正常使用。故替换之#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
int ret, i, status;
char *child_argv[200] = {"/usr/share/TSMIS/bin/TSMIS_JK"};
pid_t pid;
while(1)
{
pid = fork();
if (pid == -1)
{
fprintf(stderr, "fork() error.errno:%d error:%s\n", errno, strerror(errno));
break;
}
if (pid == 0)
{
ret = execlp(child_argv[0],child_argv[0],(char*)0);
if (ret < 0)
{
fprintf(stderr, "execv ret:%d errno:%d error:%s\n", ret, errno, strerror(errno));
continue;
}
exit(0);
}
if (pid > 0)
{
//pid = wait(&status);
//
waitpid(pid,&status,0);
fprintf(stdout, "wait return");
sleep(5);
}
}
return 0;
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
int ret, i, status;
char *child_argv[200] = {"/usr/share/TSMIS/bin/TSMIS_JK"};
pid_t pid;
while(1)
{
pid = fork();
if (pid == -1)
{
fprintf(stderr, "fork() error.errno:%d error:%s\n", errno, strerror(errno));
break;
}
if (pid == 0)
{
ret = execlp(child_argv[0],child_argv[0],(char*)0);
if (ret < 0)
{
fprintf(stderr, "execv ret:%d errno:%d error:%s\n", ret, errno, strerror(errno));
continue;
}
exit(0);
}
if (pid > 0)
{
//pid = wait(&status);
//
waitpid(pid,&status,0);
fprintf(stdout, "wait return");
sleep(5);
}
}
return 0;
}