Re: Signal Handlers - sort of mystified by this
- From: Rich Teer <rich.teer@xxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 16:47:29 GMT
On Fri, 30 Dec 2005, Chad wrote:
> Why can't printf() be used inside a signal handler? If printf() can't
Because printf and many other functions aren't reenterant and/or may
alter global state.
> be used inside a signal handler, then how come Dr. W Richard Stevens
> does it on page 133 of book "Unix Network Programming: The Sockets API"
> (3rd edition)
Sometimes when writing example programs, making them 100% technically
correct, complete with all error checking, can obfuscate the point the
example is tryng to illustrate. When you know what you're doing, then
it is possible to bend the rules. Yes, printf shouldn't be used in a
signal handler, but in a relatively simple single threaded example
program, what can go wrong?
The trick is to be aware of the technicalities, and apply them when
necessary.
> Going on. Is this by any chance related to the fact that in the book
> Unix Network Programming: The Sockets API", they use POSIX standards,
> while on comp.lang.c, they use ANSI standards?
Nope.
--
Rich Teer, SCNA, SCSA, OpenSolaris CAB member
. * * . * .* .
. * . .*
President, * . . /\ ( . . *
Rite Online Inc. . . / .\ . * .
.*. / * \ . .
. /* o \ .
Voice: +1 (250) 979-1638 * '''||''' .
URL: http://www.rite-group.com/rich ******************
.
- Follow-Ups:
- Re: Signal Handlers - sort of mystified by this
- From: SM Ryan
- Re: Signal Handlers - sort of mystified by this
- References:
- Signal Handlers - sort of mystified by this
- From: Chad
- Signal Handlers - sort of mystified by this
- Prev by Date: Re: Recording read hits on a file
- Next by Date: Re: Signal Handlers - sort of mystified by this
- Previous by thread: Re: Signal Handlers - sort of mystified by this
- Next by thread: Re: Signal Handlers - sort of mystified by this
- Index(es):
Relevant Pages
|
|