Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pid_t pid;
- pid=fork();
- if (pid == 0)
- {
- //In child
- execl("/bin/sh", "sh", "-c", "/opt/qcom/bin/version.out > /tmp/version", (char *)NULL);
- exit(0);
- }
- else
- {
- // In parent, wait for 1 second
- sleep(1);
- int status;
- if (waitpid(pid, &status, WNOHANG) != pid)
- {
- //kill(pid, SIGTERM); //--> tried this too
- kill(pid, SIGKILL);
- }
- fsmverDir("/tmp/version");
- system("rm /tmp/version");
- }
- # ps | grep "version.out|sh"
- 2012 root 0 Z [sh]
- 2013 root 13236 S /opt/qcom/bin/version.out
- 2058 root 0 Z [sh]
- 2059 root 13236 S /opt/qcom/bin/version.out
- 2092 root 0 Z [sh]
- 2093 root 13236 S /opt/qcom/bin/version.out
- 2100 root 2360 S grep version.out|sh
- #
- execlp("timeout","timeout","1","sh","-c","/opt/qcom/bin/version.out > /tmp/version",NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement