Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!tektronix!hplabs!sri-unix!LeFebvre.wbst@XEROX.ARPA From: LeFebvre.wbst@XEROX.ARPA Newsgroups: net.unix-wizards Subject: Re: The errno variable can get trashed Message-ID: <798@sri-arpa.UUCP> Date: Mon, 6-Aug-84 10:31:00 EDT Article-I.D.: sri-arpa.798 Posted: Mon Aug 6 10:31:00 1984 Date-Received: Thu, 9-Aug-84 01:13:24 EDT Lines: 23 > The solution would seem to be to have the C signal handling mechanism > save errno before calling the signal routine and restore it after > the routine has returned. Alternatively (actually, in lieu of), the signal handling routine itself could save and restore the value of errno. It is possible to assign errno a value explicitly. The routine "i" in your example could be written: void i() { int olderrno; /* note the name is exactly 8 characters :-) */ olderrno = errno; signal(SIGALRM,i); open(".",1); /* Fails, since is a directory */ errno = olderrno; } Of course, you also have to move the definition of errno to before the "void i" statement. William LeFebvre Department of Computer Science Rice University At Xerox for the summer (but not much longer)