[comp.unix.questions] How can two modules within a single process share alarm handling?

neal@druhi.ATT.COM (Neal D. McBurnett) (11/17/88)

I am helping to write a system which is delivered to users as a C library.
We need to be able to wait for certain events, but in case they never occur,
we use the signal() and alarm() calls to regain control without hanging.

The problem is that the users of our system also want to use alarms.

I note that the sleep() function is clever enough to be called even if
the process is already using alarm() and signal(), and that makes me
optimistic that a similar scheme could be used to provide a general-purpose
routine or two which would allow 2 independent modules within a process to
share the alarm and signal resources.  On the other hand, signals and alarms
are pretty kludgy things in Unix, and they vary across different Unix
releases.  I am currently interested in a solution for System V R3, but
we may in the future also want to support Sun workstations, etc.

Has anyone done this, or has anyone determined that it cannot, in general,
be done?  Even a limited implementation which only worked for 2 independent
modules under System V would be of great interest.

Thank you!

-Neal McBurnett, att!druhi!neal