home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_07 / 9n07106a < prev    next >
Text File  |  1991-05-28  |  789b  |  52 lines

  1. /* all_true.c */
  2. /* ---------- */
  3. /*
  4. No matter what code the calling program returns, this 
  5. program will always return 0 (success).
  6.  
  7. Usage:  all_true program args
  8. Example: all_true sleep 5
  9.  
  10. */
  11.  
  12.  
  13. #include <stdio.h>
  14. #include <signal.h>
  15.  
  16. #define RET_VALUE        0
  17.  
  18. main(argc,argv)
  19. int argc;
  20. char **argv;
  21. {
  22. process(argc,argv);
  23. exit(RET_VALUE);
  24. }
  25.  
  26. process(argc,argv)
  27. int argc;
  28. char **argv;
  29. {
  30. int pid;
  31.  
  32. if ((pid = fork()) == -1)
  33.   {
  34.   perror("all_true");
  35.   exit(1);
  36.   }
  37.  
  38. if (pid > 0 )
  39.  {
  40.  signal(SIGINT,SIG_IGN); /* Ignore interrupt key */
  41.  while (wait( (int *) 0 ) == pid);
  42.  return;
  43.  }
  44.  
  45. signal(SIGINT,SIG_DFL);  /* Default interrupt key */
  46. argv++;                  /* Point to program argument */
  47. execvp(*argv, argv);
  48. perror("all_true");
  49. }
  50.  
  51.  
  52.