This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: Symlinks under /proc
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: cygwin-developers at cygwin dot com
- Date: Mon, 31 Jan 2005 19:02:54 -0500 (EST)
- Subject: Re: Symlinks under /proc
- References: <20050129115137.GA3435@cygbert.vinschen.de><048801c5062d$176ab010$0207a8c0@avocado> <20050131103635.GB19009@cygbert.vinschen.de><Pine.GSO.4.61.0501311218420.28344@slinky.cs.nyu.edu><20050131173157.GH31117@cygbert.vinschen.de> <Pine.GSO.4.61.0501311240520.28344@slinky.cs.nyu.edu><20050131210310.GA24285@cygbert.vinschen.de>
- Reply-to: cygwin-developers at cygwin dot com
On Mon, 31 Jan 2005, Corinna Vinschen wrote:
> On Jan 31 12:43, Igor Pechtchanski wrote:
> > On Mon, 31 Jan 2005, Corinna Vinschen wrote:
> > > On Jan 31 12:20, Igor Pechtchanski wrote:
> > > > That's cool. Don't want to seem pushy, but how hard would it be
> > > > to go from the above to /dev/std{in,out,err}? Come to think of
> > > > it, it may even be as easy as "ln -s /proc/self/fd/0 /dev/stdin",
> > > > etc... That would really help some apps, especially those that
> > > > don't understand the "-" filename argument.
> > >
> > > Why don't you just try it? Experiments are the bread and butter of
> > > progress, aren't they?
> >
> > D'oh! After all this thought process, I looked on Linux, and that's
> > *exactly* how /dev/std* are implemented there.
>
> Talking about experiments, did you also try it on Cygwin if it works or
> did you just look on Linux how it's implemented there?
I tried it on the CVS HEAD. Making /dev/stdin a symlink works wherever
/proc/self/fd/0 works (as expected).
Both work perfectly for programs invoked directly from the bash command
line. Pipes are another story. The following fails for me:
$ echo "blaaah" | perl -pe 's/aaa/bbb/g' /proc/self/fd/0
Can't open /proc/self/fd/0: No such file or directory.
This shows some more detail:
$ echo "blaaah" | perl -e 'print `ls -l /proc/self/fd/0 2>&1`,`ls -lL /proc/self/fd/0 2>&1`'
lrwxrwxrwx 1 igor root 0 Jan 31 18:54 /proc/self/fd/0 -> pipe:[1700]
ls: /proc/self/fd/0: No such file or directory
Could it be that the pipe is closed before the child process completes?
But no, making the first process in the pipe longer-running doesn't help:
$ (echo "blaaah";sleep 10;echo "blaaarg") | perl -e 'print `ls -lL /proc/self/fd/0`'
$ (echo "blaaah";sleep 10;echo "blaaarg") | perl -e 'print `ls -l /proc/self/fd/0 2>&1`,`ls -lL /proc/self/fd/0 2>&1`'
lrwxrwxrwx 1 igor root 0 Jan 31 18:54 /proc/self/fd/0 -> pipe:[1700]
ls: /proc/self/fd/0: No such file or directory
Doesn't look like the symlink target is valid. I have the strace output,
but unfortunately, I don't have time at the moment to look at it in more
detail. I can send it if needed. Sorry I couldn't be more helpful.
Igor
P.S. "uname -orv" shows "1.5.13(0.118/4/2) 2005-01-31 18:09 Cygwin"
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT