Quote:
Originally Posted by
Corona688
Interesting. That'll take some careful use of signals though, whether a system call returns with SIGINT when interrupted is optional, and not all systems have the same default.
That's why you use sigaction; if you want the system call to restart after signal then supply the SA_RESTART flag, otherwise, don't and you'll get SIGINT. While the default behavior may be different across systems, sigaction insures you get the behavior you want. This is why sigaction is preferred over signal for portable code.
edit: as an aside, when we ported a large system from HP-UX to Linux this was a big problem. The team doing the port didn't understand signals very well in general, and the default behavior of a handler installed with signal in HP-UX is different from Linux. They had lots of issues, and I had to explain quite a bit to them to get things working right. Linux was also a lot less forgiving of their dumb use of sigblock and sigunblock to "protect" them from reentering a signal handler. This stupidity caused some very interesting stack traces until I explained the right way to do it was to provide the correct signal mask to sigaction so the block/unblock would occur atomically with the calling of the signal.... Ahh...good times with less than stellar developers, lol.
Quote:
Originally Posted by
Corona688
Maybe not on your system, but some sure do.
I suppose the man page for sleep does mention SIGALRM may be used to implement sleep, but have you seen one actually do it?