home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 10843 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.9 KB

  1. Path: sparky!uunet!gatech!rpi!scott.skidmore.edu!psinntp!psinntp!rsi!prcrs!paul
  2. From: paul@prcrs.prc.com (Paul Hite)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: changing name of core file
  5. Message-ID: <4750@prcrs.prc.com>
  6. Date: 8 Sep 92 21:43:18 GMT
  7. References: <1992Sep3.210650.65595@evolving.com>
  8. Organization: PRC Realty Systems, McLean, VA
  9. Lines: 36
  10.  
  11. In article <1992Sep3.210650.65595@evolving.com>, dxs@evolving.com (Dan Stanger) writes:
  12. > does anyone know how to change the name of the core file that will be
  13. > created if a program fails.  we have several programs running in the
  14. > same directory so if more than one of them fails the core file from
  15. > one overwrites the other.  we would like to change the name to
  16. > program.core or somthing like that.
  17.  
  18. Core is dropped when a signal is received.  You can install a signal
  19. handler to catch the signal(s) and do some special processing.
  20.  
  21. One way the signal handler could work is to:
  22.     create a new directory
  23.     cd to it
  24.     remove the signal handler  (not needed with SysV)
  25.     send the signal to yourself again
  26. You will drop core in the new directory.  Thus you'd have
  27.     ./core1/core
  28.     ./core2/core
  29.     ./core3/core
  30.     ...
  31.  
  32. There's still a chance that two processes would both try to make,
  33. say, ./core2 at the same time.  If that's really an issue you
  34. could use file locking, semaphores, links to directories, or
  35. some other way of handling the race condition.  It's hard to be
  36. specific since you failed to mention what system you're using.
  37.  
  38. If the core file *must* be renamed, you could get fancier.  The signal
  39. handler could fork.  The child would dump core.  The parent would wait 
  40. for the child to exit and then rename the core file.
  41.  
  42. But personally, I'd just run the programs in different directories :-)
  43.  
  44. Paul Hite   PRC Realty Systems  McLean,Va   paul@prcrs.prc.com    (703) 556-2243
  45.     "We are trying to bring up an Air Traffic Control display on an X window 
  46.       terminal and there seems to be some problems." -- from comp.windows.x
  47.