Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #ifdef HAVE_NEXT |
Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 4 | #include <errno.h> |
Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 5 | #include "next-posix.h" |
| 6 | |
| 7 | int |
| 8 | waitpid(int pid, int *stat_loc, int options) |
| 9 | { |
| 10 | if (pid <= 0) { |
| 11 | if (pid != -1) { |
| 12 | errno = EINVAL; |
| 13 | return -1; |
| 14 | } |
| 15 | pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */ |
| 16 | } |
| 17 | return wait4(pid, (union wait *)stat_loc, options, NULL); |
| 18 | } |
| 19 | |
| 20 | pid_t setsid(void) |
| 21 | { |
| 22 | return setpgrp(0, getpid()); |
| 23 | } |
| 24 | |
| 25 | int |
| 26 | tcgetattr(int fd, struct termios *t) |
| 27 | { |
| 28 | return (ioctl(fd, TIOCGETA, t)); |
| 29 | } |
| 30 | |
| 31 | int |
| 32 | tcsetattr(int fd, int opt, const struct termios *t) |
| 33 | { |
| 34 | struct termios localterm; |
| 35 | |
| 36 | if (opt & TCSASOFT) { |
| 37 | localterm = *t; |
| 38 | localterm.c_cflag |= CIGNORE; |
| 39 | t = &localterm; |
| 40 | } |
| 41 | switch (opt & ~TCSASOFT) { |
| 42 | case TCSANOW: |
| 43 | return (ioctl(fd, TIOCSETA, t)); |
| 44 | case TCSADRAIN: |
| 45 | return (ioctl(fd, TIOCSETAW, t)); |
| 46 | case TCSAFLUSH: |
| 47 | return (ioctl(fd, TIOCSETAF, t)); |
| 48 | default: |
| 49 | errno = EINVAL; |
| 50 | return (-1); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | int tcsetpgrp(int fd, pid_t pgrp) |
| 55 | { |
| 56 | int s; |
| 57 | |
| 58 | s = pgrp; |
| 59 | return (ioctl(fd, TIOCSPGRP, &s)); |
| 60 | } |
| 61 | |
| 62 | speed_t cfgetospeed(const struct termios *t) |
| 63 | { |
| 64 | return (t->c_ospeed); |
| 65 | } |
| 66 | |
| 67 | speed_t cfgetispeed(const struct termios *t) |
| 68 | { |
| 69 | return (t->c_ispeed); |
| 70 | } |
| 71 | |
| 72 | int |
| 73 | cfsetospeed(struct termios *t,int speed) |
| 74 | { |
| 75 | t->c_ospeed = speed; |
| 76 | return (0); |
| 77 | } |
| 78 | |
| 79 | int |
Damien Miller | 31abc9a | 2000-07-09 23:26:27 +1000 | [diff] [blame] | 80 | cfsetispeed(struct termios *t, int speed) |
Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 81 | { |
| 82 | t->c_ispeed = speed; |
| 83 | return (0); |
| 84 | } |
Damien Miller | 0f91b4e | 2000-06-18 15:43:25 +1000 | [diff] [blame] | 85 | #endif /* HAVE_NEXT */ |