Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. pid_t pid;
  2. pid=fork();
  3. if (pid == 0)
  4. {
  5. //In child
  6. execl("/bin/sh", "sh", "-c", "/opt/qcom/bin/version.out > /tmp/version", (char *)NULL);
  7. exit(0);
  8. }
  9. else
  10. {
  11. // In parent, wait for 1 second
  12. sleep(1);
  13. int status;
  14. if (waitpid(pid, &status, WNOHANG) != pid)
  15. {
  16. //kill(pid, SIGTERM); //--> tried this too
  17. kill(pid, SIGKILL);
  18. }
  19. fsmverDir("/tmp/version");
  20. system("rm /tmp/version");
  21. }
  22.  
  23. # ps | grep "version.out|sh"
  24. 2012 root 0 Z [sh]
  25. 2013 root 13236 S /opt/qcom/bin/version.out
  26. 2058 root 0 Z [sh]
  27. 2059 root 13236 S /opt/qcom/bin/version.out
  28. 2092 root 0 Z [sh]
  29. 2093 root 13236 S /opt/qcom/bin/version.out
  30. 2100 root 2360 S grep version.out|sh
  31. #
  32.  
  33. execlp("timeout","timeout","1","sh","-c","/opt/qcom/bin/version.out > /tmp/version",NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement