home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / hp / 8575 < prev    next >
Encoding:
Text File  |  1992-07-27  |  2.2 KB  |  73 lines

  1. Newsgroups: comp.sys.hp
  2. Path: sparky!uunet!ncube.com!db1!russell
  3. From: russell@ncube.com
  4. Subject: Re: Inhibiting core dumps on HP7xx
  5. Message-ID: <1992Jul27.165150.19339@ncube.com>
  6. Sender: usenet@ncube.com
  7. Nntp-Posting-Host: db1_pdx
  8. Organization: nCUBE CORPORATION
  9. References:  <l6pa0tINNnd4@girtab.usc.edu> <1992Jul24.145006.20539@hubcap.clemson.edu>
  10. Date: Mon, 27 Jul 1992 16:51:50 GMT
  11. Lines: 60
  12.  
  13. In article <1992Jul24.145006.20539@hubcap.clemson.edu>, elwin@gamma.phys.clemson.edu (Lawrence E. Brown) writes:
  14. |> I'm very tired of frequent dumps of 10-40Meg core files every
  15. |> time I have a floating exception somewhere in my code (mostly
  16. |> Fortran some C).  Is there any way to prevent core dumps in
  17. |> HPUX8.0x on an HP700 series machine? 
  18.  
  19. I posted this recently ...
  20.  
  21. Thanks to a wonderful example from hooft@prl.philips.nl (who pointed out that
  22. the BSD hooks are still in HP-UX), I ended up with the program "nocore",
  23. which you can say:
  24.   nocore progname argument1 argument2
  25. instead of just:
  26.   progname argument1 argument2
  27.  
  28. There is no way of setting it for your current shell.  But you can start a
  29. new shell with "nocore $SHELL" (the limit will then be set for the new
  30. shell's child processes).
  31.  
  32. Good luck!
  33.  
  34. Russell Randolph
  35. nCUBE, Beaverton, Oregon
  36. russell@ncube.com
  37.  
  38. ---------------------------------  nocore.c  -----------------------------------
  39. /* Prevents core dumps from whatever is run.
  40.  * Tested on HP-UX 8.07 on 7xx series.
  41.  * To compile: cc -o nocore -I/etc/conf/h -D_KERNEL nocore.c
  42.  * Modified from example program by (hooft@prl.philips.nl)
  43.  * Russell Randolph (russell@ncube.com)
  44.  */
  45. #include <stdio.h>
  46. #include <signal.h>
  47. #include <sys/syscall.h>
  48. #include <sys/resource.h>
  49. #include <sys/time.h>
  50.  
  51. main(argc,argv)
  52.   int argc;
  53.   char *argv[];
  54. {
  55.     struct rlimit rl;
  56.  
  57.     if (!argc) {
  58.       fprintf(stderr,"Usage:    nocore <programname> [arguements ...]\n");
  59.       fprintf(stderr,"Example:  nocore spice -b circuit.sp\n");
  60.       fprintf(stderr,"Example:  exec nocore $SHELL\n");
  61.       fprintf(stderr,"Note:  child processes will also have their limits set to 0 bytes.\n");
  62.       exit(1);
  63.     }
  64.     getrlimit(RLIMIT_CORE, &rl);
  65.     rl.rlim_cur = 0;
  66.     setrlimit(RLIMIT_CORE, &rl);
  67.     *argv++;
  68.     execvp(*argv,argv);
  69.     fprintf(stderr,"Error:  execvp of %s failed.\n", *argv);
  70.     exit(1);
  71. }
  72.  
  73.