public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Ferber <aferber@techfak.uni-bielefeld.de>
To: Rob Landley <landley@trommello.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Really odd behavior of overlapping named pipes?
Date: Sat, 26 Jan 2002 05:47:40 +0100	[thread overview]
Message-ID: <20020126054740.A30571@devcon.net> (raw)
In-Reply-To: <20020126021610.YKAU20810.femail29.sdc1.sfba.home.com@there>
In-Reply-To: <20020126021610.YKAU20810.femail29.sdc1.sfba.home.com@there>; from landley@trommello.org on Fri, Jan 25, 2002 at 01:13:58PM -0500

On Fri, Jan 25, 2002 at 01:13:58PM -0500, Rob Landley wrote:
> 
> int pipes[2];
> 
> pipe(pipes)
> dup2(pipes[0],0);
> close(pipes[0]);
> 
> Boom: the pipe is no longer usable.  The stdin instance of it is closed too.  
> Read from it you get an error.  (But if I DON'T close it, I'm leaking file 
> handles, aren't I?  AAAAAAAAH!)

Did you close stdin before the pipe()? If so, the read end of the pipe
will get descriptor 0, the dup2() has actually no effect, and with the
close() you just closed stdin again.

Andreas
-- 
       Andreas Ferber - dev/consulting GmbH - Bielefeld, FRG
     ---------------------------------------------------------
         +49 521 1365800 - af@devcon.net - www.devcon.net

  reply	other threads:[~2002-01-26  4:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-25 18:13 Really odd behavior of overlapping named pipes? Rob Landley
2002-01-26  4:47 ` Andreas Ferber [this message]
2002-01-26  9:07 ` H. Peter Anvin
2002-01-27  1:09   ` Chris Wedgwood
2002-01-27  1:14     ` H. Peter Anvin

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=20020126054740.A30571@devcon.net \
    --to=aferber@techfak.uni-bielefeld.de \
    --cc=landley@trommello.org \
    --cc=linux-kernel@vger.kernel.org \
    /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