public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Patrick Doyle <wpd@delcomsys.com>
To: cygwin@cygwin.com
Subject: Re: Why does scp leave ssh running? -- select() never returns
Date: Sat, 06 Jan 2001 19:21:00 -0000	[thread overview]
Message-ID: <3A57E0F0.3FE252BD@delcomsys.com> (raw)
In-Reply-To: <3A352393.4D8645EC@delcomsys.com>

I have been working on a hack workaround for this problem.  (Short
summary -- select() fails to detect when all of the writers of a pipe
have closed the pipe because PeekNamedPipe() on W9x boxen fails to
report when all of the writers of a pipe have closed the pipe.  I am
told that this all works correctly on NT/2K boxen).

Basically, I have modified 'pipe()' to create two windows pipes (on W9x
boxen).  The first pipe is the same one that has always been created. 
The second one is used simply to pass EOF information to the reader of
the (main) pipe.  So, I modified (or rather, created)
fhandler_pipe::close(), which posts an "EOF" message to the 2nd pipe and
I created fhandler_pipe::dup() and fhandler_pipe::fixup_after_fork() to
post a "DUP" message to the 2nd pipe.  Finally, I modified the
processing for select() on an input pipe to check the 2nd pipe, count
the number of DUP and EOF messages, and return "READY" when all of the
writers have closed the pipe.  As I said, it's a hack, but it is one
that only activates on W9x boxen, so it shouldn't be too horrible.

My current problem is, "How do I handle exec()"?  When the new process
is started, I see that handles to both pipes will be inherited by the
exec'd process, but I have no idea how to re-associate the two of them
with each other.  In my search for an answer, I have gotten more and
more confused.  How do fhandlers get recreated for all of the open fd's
in the newly exec'd process?  I see stdio_init(), which creates
fhandlers for fd's 0, 1, and 2, but what about the rest of the open
fd's.  I don't really need an answer to that, but it will keep me
puzzled for weeks.  What I really need an answer to is, "How can an
exec'd process know things about the state of the orignal process,
specifically, what handles were associated with which fhandler objects?"

Am I off on the totally wrong track?  From what I see in spawn.cc, I
think that the exec'd process will start at ground zero, with regard to
the cygwin library.  Somehow information about the fdtab needs to be
communicated to the new process.  I see pointers from the parent process
being passed to the exec'd process via the STARTUPINFO structure, but I
don't see anything like what is in fork.cc, wherein memory regions are
physically copied from one process to the other.  What am I missing. 
(And, BTW, the MSDN documentation for STARTUPINFO says that lpReserved2
must be set to NULL -- you set it to &ciresrv -- how can you get away
with doing something that the MSDN docs say you shouldn't?)

I appreciate any an all pointers that folks would care to give me
regarding this.

TIA

--wpd

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

  parent reply	other threads:[~2001-01-06 19:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-27 12:26 Why does scp leave ssh running? Patrick Doyle
2000-11-28  2:12 ` Graham Bloice
2000-11-29 19:21 ` Why does scp leave ssh running? -- select() never returns Patrick Doyle
2000-11-29 19:41   ` Christopher Faylor
2000-11-30  6:15     ` Patrick Doyle
2000-11-30  6:35       ` Corinna Vinschen
2000-11-30  7:05         ` Patrick Doyle
2000-11-30 19:40       ` Patrick Doyle
2000-12-02 17:08         ` Christopher Faylor
2000-12-02 19:47           ` Patrick Doyle
2000-12-02 20:39             ` Christopher Faylor
2000-12-03  1:47               ` Corinna Vinschen
2000-12-11 10:19                 ` Patrick Doyle
2000-12-11 10:36                   ` Christopher Faylor
2000-12-11 10:56                     ` Patrick Doyle
2000-12-11 11:08                       ` Christopher Faylor
2001-01-06 19:21                       ` Patrick Doyle [this message]
2001-01-08  3:21                         ` Ehud Karni
2001-01-08  6:24                           ` Patrick Doyle
2000-12-12  5:46                   ` David Starks-Browning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A57E0F0.3FE252BD@delcomsys.com \
    --to=wpd@delcomsys.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).