1 /* Yes, that's right: of all the platforms supported by ppp,
2 only Mach OpenStep 4.x doesn't support POSIX. Sheesh.
4 Stranger still, the POSIX declatations are still in the 4.x header files,
5 and the gcc -posix still defines _POSIX_SOURCE. So...
6 we emulate (sometimes badly) the missing POSIX functions. This
7 is by no means a complete or general POSIX emulation. Just enough
8 to get us by for ppp, so we don't have to pollute the rest of the
9 sources of every other (non-braindead) platform. Much of the
10 code was snarfed from NeXT's 4.0 ppp port, the rest inspired by
11 "POSIX Programmers Guide" by Donald Lewine.
13 Maybe if we complain NeXT will upgrade to BSD4.4 libs like the rest of
14 the free world (and maybe pink elephants will fly out of my... -KC)
20 #include <sys/ioctl.h>
24 int sigemptyset(sigset_t *set)
30 int sigaddset(sigset_t *set, int signo)
36 int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
40 *oset = sigblock(*set);
43 /* XXX How does one emulate this with ancient BSD? (KC) */
46 *oset = sigsetmask(*set);
52 int sigsuspend(const sigset_t *sigmask)
57 int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
59 struct sigvec vec, ovec;
62 vec.sv_handler = act->sa_handler;
63 vec.sv_mask = act->sa_mask;
64 vec.sv_flags = act->sa_flags;
66 st = sigvec(sig, &vec, &ovec);
69 oact->sa_handler = ovec.sv_handler;
70 oact->sa_mask = ovec.sv_mask;
71 oact->sa_flags = ovec.sv_flags;
77 int tcgetattr(int fildes, struct termios *tp)
79 return ioctl(fildes, TIOCGETA, tp);
82 int tcsetattr(int fd, int opt, const struct termios *t)
88 st = ioctl(fd, TIOCSETA, t);
91 st = ioctl(fd, TIOCSETAW, t);
94 st = ioctl(fd, TIOCSETAF, t);
104 /* XXX we ignore duration (which is 0 in chat.c anyway).
106 int tcsendbreak(int fildes, int duration)
108 struct timeval sleepytime;
110 sleepytime.tv_sec = 0;
111 sleepytime.tv_usec = 400000;
112 if (ioctl(fildes, TIOCSBRK, 0) != -1)
114 select(0, 0, 0, 0, &sleepytime);
115 (void) ioctl(fildes, TIOCCBRK, 0);
119 /* XXX This is the implementation of cfgetospeed from NeXT's ppp-5
120 pppd/sys-NeXT.c. I don't know whether returning c_ispeed instead
121 of c_ospeed is deliberate or a type-o.
123 speed_t cfgetospeed(const struct termios *t)
128 int cfsetospeed(struct termios *t, int speed)
134 speed_t cfgetispeed(const struct termios *t)
139 int cfsetispeed(struct termios *t, int speed)
149 setpgrp(0, getpid());
151 if ( (fd = open("/dev/tty", O_RDWR | O_NDELAY)) < 0)
153 ioctl(fd, TIOCNOTTY, NULL);
159 int waitpid(pid_t pid, int *stat_loc, int options)
163 return wait4(pid, (union wait *) stat_loc, options, NULL);