1 /* ttym.c - miscellaneous routines */
3 static char ident[] = "@(#)$Id: ttym.c,v 1.6 1992/02/03 17:57:22 jromine Exp $";
16 static ttym (fd, command, line, user, vec)
33 struct passwd *getpwuid ();
35 #endif /* !__STDC__ */
37 if ((term = ap = ttyname (2)) && (term = rindex (term, '/')))
39 if (term == NULL || *term == NULL)
41 if ((myself = getlogin ()) == NULL || *myself == NULL)
42 myself = (pw = getpwuid (getuid ())) ? pw -> pw_name : NULL;
44 pstat = signal (SIGPIPE, SIG_IGN);
45 (void) write (fd, command, strlen (command));
46 (void) write (fd, "", 1);
49 (void) write (fd, term, strlen (term));
50 (void) write (fd, "", 1);
53 (void) write (fd, myself, strlen (myself));
54 (void) write (fd, "", 1);
57 (void) write (fd, line, strlen (line));
58 (void) write (fd, "", 1);
61 (void) write (fd, user, strlen (user));
62 (void) write (fd, "", 1);
66 (void) write (fd, ap, strlen (ap));
67 (void) write (fd, "", 1);
70 (void) write (fd, "", 1);
71 (void) signal (SIGPIPE, pstat);
85 nbits = getdtablesize();
88 if (select (nbits, &ifds, (int *) 0, (int *) 0, &tv) <= 0
89 || read (fd, &c, 1) != 1)
95 (void) ttyf (fd, stderr);
100 static int ttyf (fd, f)
107 while ((i = read (fd, buffer, sizeof buffer)) > 0)
108 (void) fwrite (buffer, sizeof (char), i, f);