blob: 0f0c0ea497ca10198a2aa27ded2e05806d01e8ab [file] [log] [blame]
Damien Miller0f91b4e2000-06-18 15:43:25 +10001#include "config.h"
2
3#ifdef HAVE_NEXT
Damien Miller0f91b4e2000-06-18 15:43:25 +10004#include <errno.h>
Damien Miller0f91b4e2000-06-18 15:43:25 +10005#include "next-posix.h"
6
7int
8waitpid(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
20pid_t setsid(void)
21{
22 return setpgrp(0, getpid());
23}
24
25int
26tcgetattr(int fd, struct termios *t)
27{
28 return (ioctl(fd, TIOCGETA, t));
29}
30
31int
32tcsetattr(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
54int tcsetpgrp(int fd, pid_t pgrp)
55{
56 int s;
57
58 s = pgrp;
59 return (ioctl(fd, TIOCSPGRP, &s));
60}
61
62speed_t cfgetospeed(const struct termios *t)
63{
64 return (t->c_ospeed);
65}
66
67speed_t cfgetispeed(const struct termios *t)
68{
69 return (t->c_ispeed);
70}
71
72int
73cfsetospeed(struct termios *t,int speed)
74{
75 t->c_ospeed = speed;
76 return (0);
77}
78
79int
Damien Miller31abc9a2000-07-09 23:26:27 +100080cfsetispeed(struct termios *t, int speed)
Damien Miller0f91b4e2000-06-18 15:43:25 +100081{
82 t->c_ispeed = speed;
83 return (0);
84}
Damien Miller0f91b4e2000-06-18 15:43:25 +100085#endif /* HAVE_NEXT */