This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tcgetpgrp


On Oct  8 14:35, Andy Koppe wrote:
> >>> * fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
> >>> valid pgid if tty is controlling tty.  Set errno to ENOTTY and
> >>> return -1 otherwise.
> 
> > Thanks for the testcase. ?Here's what I see on Linux:
> >
> > ?$ gcc -g openpty.c -o openpty -lutil
> > ?$ ./openpty
> > ?-1
> 
> Fair enough, but it's still a change in Cygwin behaviour, which is why
> I'm wondering whether it's really necessary? I can't see any reason

Actually, it's not just a change, it's a bug fix.  The reason for the
fix is that POSIX requires this behaviour.  When I debugged the luit
problem I found that tcsh, for instance, depends on this behaviour.

> for that restriction from a security perspective, so does anything
> depend on -1 being returned? And is there any other (possibly
> Cygwin-specific) way to get at that information?

Not that I'm aware of.  I have to admit that I don't even know how you
could get this info on Linux without standing on your head.  The other
problem is that the information you would get from tcgetpgrp is not
safe.  You can't assume that the process still exists when you try to
fetch information from /proc/$pid.  Or worse, the process could have
exited and been replaced by another process with the same PID, given
that Windows re-uses PIDs quite liberally.  What you're trying to
accomplish looks a bit tricky and unsecure.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]