Signal handlers and errno

Jochen Manns, PI der Uni Bonn, 732738/3611 MANNS%DBNPIB5.BITNET at cunyvm.cuny.edu
Fri Jan 4 21:25:43 AEST 1991


Dear UNIX programmers,

        I got the following problem with a signal handler and the
        global 'errno' variable:

        a) there is a main program, doing something like semop or
           select in the form:
                while ( system_call() == -1 )
                 if ( errno != EINTR )
                  fatal_error();
        b) now, a signal handler is installed via 'alarm', which has
           various tasks. Especially it may get some 'errno' from the
           system calls it makes.
        c) so, if the handler interrupts the system_call in the main
           this call will fail with EINTR - no problem so far. But if
           the handler is called again before EINTR is checked - which
           is possible in a heavy loaded multitasking system even when
           using 'alarm' - this may crash the program when it becomes
           a modified 'errno'.

        For now I keep track on 'errno' in the signal handler but I
        want to ask you if there is no better method to solve such
        problems. Is't it a general problem with handlers? Can some
        of you give me some hints on that problem?



                        Jochen Manns
                        Physikalisches Institut der Universitaet Bonn
                        Nussallee 12
                        5300 Bonn 1
                        (Germany)



More information about the Comp.unix.questions mailing list