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