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 13:15, Andy Koppe wrote:
> 2009/10/8 Corinna Vinschen <corinna-cygwin@cygwin.com>:
> > On Oct ?8 07:34, Andy Koppe wrote:
> >> I'm having trouble with this change:
> >>
> >> ? ? ? ? * fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
> >> ? ? ? ? valid pgid if tty is controlling tty. ?Set errno to ENOTTY and
> >> ? ? ? ? return -1 otherwise.
> >>
> >> Mintty uses the following call to create its pty:
> >>
> >> ? openpty (&parent_fd, &child_fd, 0, 0, winp)
> >>
> >> It then forks a child process which calls login_tty(child_fd) and
> >> execs the shell or other command. Meanwhile, the parent mintty process
> >> retains the child_fd, so that it can find out what the current
> >> foreground process of the pty is, using tcgetpgrp(child_fd).
> >> /proc/<id>/cwd then allows it to find the current working directory of
> >> the foreground process.
> >>
> >> This is used for a new feature in mintty-0.5: Ctrl+clicking on a file
> >> to open it via cygstart, whereby the current working directory of the
> >> foreground process is needed for relative paths. This worked fine up
> >> to 1.7.0-62, but due to the change above it no longer works on
> >> cygwin-cvs.
> >>
> >> Is it really necessary to restrict tcgetpgrp() in that way? Is there
> >> any other way to find the current foreground process of a terminal?
> >
> > STC?
> 
> Here you go. Prints a process ID on 1.7.0-62, but -1 on the latest snapshot.


Thanks for the testcase.  Here's what I see on Linux:

  $ gcc -g openpty.c -o openpty -lutil
  $ ./openpty
  -1


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]