home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4610 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.4 KB  |  49 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!newsgate.watson.ibm.com!news.ans.net!ans.net!db3l
  3. From: db3l@ans.net (David Bolen)
  4. Subject: Re: DosExitList Hangs Process (OS/2 V1.3)
  5. Sender: news@ans.net (News Administrator)
  6. Message-ID: <1992Aug31.215344.36276@ans.net>
  7. In-Reply-To: rariedel@beckman.com's message of 31 Aug 92 19: 42:58 GMT
  8. Date: Mon, 31 Aug 1992 17:55:10 GMT
  9. References: <1992Aug31.124258.980@beckman.com>
  10. Organization: Advanced Network & Services, Inc. - Elmsford, NY
  11. Lines: 36
  12.  
  13. In article <1992Aug31.124258.980@beckman.com> rariedel@beckman.com (Bob Riedel) writes:
  14.  
  15. >It appears that my exit routine is not even being called since debug
  16. >printf(s) never print when this situation occurs. The program will run to
  17. >completion normally if Ctrl-C is not hit, and the exit handler is entered
  18. >and functions normally.
  19.  
  20. You might try removing any dependency upon the C run-time library in your
  21. exit handler (ie: the printf calls).  Since you can't depend upon the state
  22. of your process while exiting (especially if you have interrupted it), you
  23. should stick to OS/2 system calls.  For example, you may have interrupted your
  24. process while it was in the middle of the C library, and calling routines in
  25. the C library from the exit handler can either cause problems due to the
  26. non-reentrancy of some routines, or hanging if you are using a multi-threaded
  27. C library and it deadlocks due to internal thread-synchronization.
  28.  
  29. It's a pain, but try backing out to simple DosWrite's to stdout (you should
  30. be able to use "fileno(stdout)", or just "(HFILE)1" I think).  Or, you can
  31. create your own version of printf that is safe to call from the exit handler
  32. (ie: just uses OS/2 system calls).
  33.  
  34. Now, if you use the compiler library's capability for trapping interrupts
  35. (ie: signal(SIGINT) if supported), or program exiting (atexit() if supported),
  36. then you should be safe, since those functions are dispatched by the
  37. compiler library itself, so it gets a chance to make sure things are in order
  38. prior to calling the handlers.  Using DosExitList is going below the
  39. compiler, so it doesn't get that same chance.
  40.  
  41. --
  42. -- David
  43. --
  44. /-----------------------------------------------------------------------\
  45.  \              David Bolen             \  Internet: db3l@ans.net      /
  46.   |   Advanced Network & Services, Inc.   \   Phone: (914) 789-5327   |
  47.  / 100 Clearbrook Road, Elmsford, NY 10523  \   Fax: (914) 789-5310    \
  48. \-----------------------------------------------------------------------/
  49.