2 * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
15 /** isatty - is the given file descriptor bound to a terminal device?
16 * a simple call to fetch the terminal control attributes suffices
17 * (only a valid tty device will succeed)
23 struct termios termios
;
25 return _kern_ioctl(fd
, TCGETA
, &termios
, sizeof(struct termios
)) == B_OK
;
26 // we don't use tcgetattr() here in order to keep errno unchanged
30 /** returns the name of the controlling terminal */
35 static char defaultBuffer
[L_ctermid
];
36 char *name
= ttyname(STDOUT_FILENO
);
37 // we assume that stdout is our controlling terminal...
42 return strcpy(s
, name
? name
: "");
47 tcsetpgrp(int fd
, pid_t pgrpid
)
49 return ioctl(fd
, TIOCSPGRP
, &pgrpid
);
56 pid_t foregroundProcess
;
57 int status
= ioctl(fd
, TIOCGPGRP
, &foregroundProcess
);
59 return foregroundProcess
;