Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!caip!nike!ucbcad!ucbvax!hplabs!oracle!bradbury From: bradbury@oracle.UUCP (Robert Bradbury) Newsgroups: net.unix,net.unix-wizards Subject: Re: Not a typewriter Message-ID: <451@oracle.UUCP> Date: Sun, 6-Jul-86 14:46:27 EDT Article-I.D.: oracle.451 Posted: Sun Jul 6 14:46:27 1986 Date-Received: Sun, 27-Jul-86 06:15:20 EDT References: <1683@homxb.UUCP> <542@codas.ATT.UUCP> <717@axis.UUCP> <573@codas.ATT.UUCP> Organization: ORACLE Corporation, 20 Davis Dr., Belmont CA 94002 Lines: 33 Summary: signals and system call success vs. failure Xref: mnetor net.unix:5042 net.unix-wizards:7290 In article <573@codas.ATT.UUCP>, mikel@codas.ATT.UUCP (Mikel Manitius) writes: > > Yes, you are correct. I don't always trust the documentation, so I > rarely read it. I checked by writing a small C program, write does > indeed return -1 not 0, when the call is interrupted and no bytes > were read. > Mikel Manitius The problem is much more subtle than is indicated by this discussion. A -1 will be returned and errno set to EINTR if a signal has been received anytime from the beginning to the end of the system call. In cases where the the system call may be completed without doing a sleep() [a read from a teletype where the user has typed ahead or a write to a pipe] the system call will actually have done the work successfully even though it returns an error. This maybe I did it and maybe I didn't aspect of system calls in the presence of signals has caused me to write some very strange code from time to time. The Berkeley folks tried to solve this in 4.1 by "restarting" the system call. Does this work right all the time? It would seem the real problem revolves around the need for multiple return values from system calls and/or the ability to prevent signals (without the overhead of more system calls) for some system calls. Does anyone know if P1003 or System 5.3 have come up with solutions for this problem? -- Robert Bradbury Oracle Corporation (206) 364-1442 {ihnp4!muuxl,hplabs}!oracle!bradbury