/[inetutils]/inetutils/libinetutils/ttymsg.c
ViewVC logotype

Diff of /inetutils/libinetutils/ttymsg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by gray, Wed May 21 15:00:14 2003 UTC revision 1.16 by gray, Tue Oct 11 11:16:14 2005 UTC
# Line 102  ttymsg (struct iovec *iov, int iovcnt, c Line 102  ttymsg (struct iovec *iov, int iovcnt, c
102      {      {
103        if (errno == EBUSY || errno == EACCES)        if (errno == EBUSY || errno == EACCES)
104          return (NULL);          return (NULL);
105        (void) snprintf (errbuf, sizeof (errbuf),        snprintf (errbuf, sizeof (errbuf),
106                        "%s: %s", device, strerror (errno));                        "%s: %s", device, strerror (errno));
107        free (device);        free (device);
108        return errbuf;        return errbuf;
# Line 143  ttymsg (struct iovec *iov, int iovcnt, c Line 143  ttymsg (struct iovec *iov, int iovcnt, c
143    
144            if (forked)            if (forked)
145              {              {
146                (void) close (fd);                close (fd);
147                _exit(1);                _exit(1);
148              }              }
149            cpid = fork2 ();            cpid = fork2 ();
150            if (cpid < 0)            if (cpid < 0)
151              {              {
152                (void) snprintf (errbuf, sizeof (errbuf),                snprintf (errbuf, sizeof (errbuf),
153                                "fork: %s", strerror (errno));                                "fork: %s", strerror (errno));
154                (void) close (fd);                close (fd);
155                free (device);                free (device);
156                return (errbuf);                return (errbuf);
157              }              }
158            if (cpid)  /* Parent.  */            if (cpid)  /* Parent.  */
159              {              {
160                (void) close (fd);                close (fd);
161                free (device);                free (device);
162                return (NULL);                return (NULL);
163              }              }
164            forked++;            forked++;
165            /* wait at most tmout seconds */            /* wait at most tmout seconds */
166            (void) signal (SIGALRM, SIG_DFL);            signal (SIGALRM, SIG_DFL);
167            (void) signal (SIGTERM, SIG_DFL); /* XXX */            signal (SIGTERM, SIG_DFL); /* XXX */
168  #ifdef HAVE_SIGACTION  #ifdef HAVE_SIGACTION
169            {            {
170              sigset_t empty;              sigset_t empty;
# Line 172  ttymsg (struct iovec *iov, int iovcnt, c Line 172  ttymsg (struct iovec *iov, int iovcnt, c
172              sigprocmask (SIG_SETMASK, &empty, 0);              sigprocmask (SIG_SETMASK, &empty, 0);
173            }            }
174  #else  #else
175            (void) sigsetmask (0);            sigsetmask (0);
176  #endif  #endif
177            (void) alarm ((u_int)tmout);            alarm ((u_int)tmout);
178            (void) fcntl (fd, O_NONBLOCK, &off);            fcntl (fd, O_NONBLOCK, &off);
179            continue;            continue;
180          }          }
181        /*        /*
# Line 184  ttymsg (struct iovec *iov, int iovcnt, c Line 184  ttymsg (struct iovec *iov, int iovcnt, c
184         */         */
185        if (errno == ENODEV || errno == EIO)        if (errno == ENODEV || errno == EIO)
186          break;          break;
187        (void) close (fd);        close (fd);
188        if (forked)        if (forked)
189          _exit (1);          _exit (1);
190        (void) snprintf(errbuf, sizeof (errbuf),        snprintf(errbuf, sizeof (errbuf),
191                        "%s: %s", device, strerror (errno));                        "%s: %s", device, strerror (errno));
192        free (device);        free (device);
193        return (errbuf);        return (errbuf);
194      }      }
195    
196    free (device);    free (device);
197    (void) close (fd);    close (fd);
198    if (forked)    if (forked)
199      _exit(0);      _exit(0);
200    return (NULL);    return (NULL);

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26