Printf not working
Yeah, I know, printf is sooo easy to use how could I have a brain and not know how to use it?
Here's the code:
(printf("dhlaf: %s: Out of range error.\nValid range is 1-65536 "
"inclusive.", argv[*i])) ? raise(SIGHUP): raise(SIGABRT);
Why does printf fail?
i.e. I get a SIGHUP not a SIGABRT.
i is a pointer to a signed int.
I was writing a bunch of checks into my program so that the "impossible" was detected and reported to the user (me.)
This message was supossed to be printed if the range of numbers was not met, but was small or too large.
Unfortuatly only the first half of the printf successeds (up to the \n.)
printf returns the number of characters printed, or a negative value if an output error is encountered. Since that value is non-zero, you always get a SIGHUP. Why would you expect a SIGABRT?
The "missing" part of the output is probably still in the output buffer when the SIGHUP hits. Try appending another '\n' at the end (ie "inclusive.\n") to try to flush it out. Doing (printf(), fflush(stdout)) would also work, but that would change the evaluation of the conditional.
I must have gotten printf mixed up with so many other of the functions in c which return 0 for success and something else for failure.