From owner-freebsd-hackers Thu May 2 20:20:22 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA17188 for hackers-outgoing; Thu, 2 May 1996 20:20:22 -0700 (PDT) Received: from paris.CS.Berkeley.EDU (paris.CS.Berkeley.EDU [128.32.34.47]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA17175 for ; Thu, 2 May 1996 20:20:12 -0700 (PDT) Received: from paris.CS.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by paris.CS.Berkeley.EDU (8.6.11/8.6.9) with ESMTP id UAA18744; Thu, 2 May 1996 20:20:01 -0700 From: Josh MacDonald Message-Id: <199605030320.UAA18744@paris.CS.Berkeley.EDU> To: sclawson@bottles.cs.utah.edu (steve clawson) cc: freebsd-hackers@freebsd.org Subject: Re: stdio problem In-reply-to: Your message of "Thu, 02 May 1996 20:02:27 MDT." <199605030202.UAA07379@bottles.cs.utah.edu> Date: Thu, 02 May 1996 20:20:01 -0700 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Whether I do fclose(stdin) or close(STDIN_FILENO) makes no difference, and in fact the same problem applies. I am execing another program which then tries to freopen(...,...,stdin). > Perhaps the answers weren't very explanatory, but they were > correct. Basically, your program is at the very least non-portable, > and IMHO buggy. Calling close(0) is _not_ the proper way to `close' > stdin. This just closes file descriptior 0, but dosen't do anything > to close the stream stdin, which has user-level state. You should use > fclose() to close it if you really need to. close() isn't even in > ANSI C. Whatever... I'll just create a pipe(), close the writer, and dup the reader. -josh