Merge branch 'master' of git://git.ucc.asn.au/tpg/acess2
[tpg/acess2.git] / Usermode / Libraries / libposix.so_src / pty.c
1 /*
2  * Acess2 POSIX Emulation Layer
3  * - By John Hodge
4  * 
5  * pty.c
6  * - PTY Management
7  *
8  * BSD Conforming (Non-POSIX)
9  */
10 #include <pty.h>
11 #include <errno.h>
12 #include <unistd.h>
13 #include <acess/sys.h>
14 #include <acess/devices.h>
15 #include <acess/devices/pty.h>
16
17 // === CODE ===
18 int openpty(int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp)
19 {
20         errno = ENOTIMPL;
21         return -1;
22 }
23
24 pid_t forkpty(int *amaster, char *name, const struct termios *termp, const struct winsize *winp)
25 {
26         int child;
27         
28         int ret = openpty(amaster, &child, name, termp, winp);
29         if(ret) return -1;
30         
31         pid_t rv = fork();
32         if(rv)  return rv;
33
34         login_tty(child);
35
36         // In child
37         dup2(child, 0);
38         dup2(child, 1);
39         dup2(child, 2);
40         close(child);
41
42         return 0;
43 }
44
45 // - utmp.h?
46 int login_tty(int fd)
47 {
48         // nop!
49         return 0;
50 }

UCC git Repository :: git.ucc.asn.au