* fhandler.h (fhandler_pty_master::tcgetpgrp): Declare.

* fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
	valid pgid if tty is controlling tty.  Set errno to ENOTTY and
	return -1 otherwise.
	(fhandler_pty_master::tcgetpgrp): New function.  Return 0 for
	master side of pty if it's not the controlling tty of the process.
This commit is contained in:
Corinna Vinschen
2009-10-07 07:52:30 +00:00
parent bd45d6fa76
commit b4311a9067
3 changed files with 20 additions and 1 deletions

View File

@@ -99,7 +99,16 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
int
fhandler_termios::tcgetpgrp ()
{
return tc->pgid;
if (myself->ctty != -1 && myself->ctty == tc->ntty)
return tc->pgid;
set_errno (ENOTTY);
return -1;
}
int
fhandler_pty_master::tcgetpgrp ()
{
return myself->ctty != -1 && myself->ctty == tc->ntty ? tc->pgid : 0;
}
void