[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mkdir with closed stdout

From: Jon Hitchcock
Subject: mkdir with closed stdout
Date: Thu, 11 Oct 2001 16:12:18 +0100

If you execute mkdir version 4.0x with stdout closed it creates
the directory, writes an error message to stderr, and exits with
status 1.  POSIX-2 says that the standard output shall not be
written when the utility is used as described by POSIX-2, so it
should not matter whether it is closed or open.

To demonstrate this:

$ mkdir xyz 1>&-
mkdir: write error: Bad file descriptor
$ echo $?
$ rmdir xyz

I discovered this when running a very old program that, for
reasons of portability, creates a directory by forking, closing
stdin, stdout and stderr, execing "mkdir", and testing the exit
status.  It believes that mkdir has failed.

Jan Kasprzak has a patch which claims to address this issue at
but it does not appear to be included in fileutils-4.1.

Jon Hitchcock
Uniplex Ltd, 126 Hempstead Road, Kings Langley, Herts, WD4 8AL
E-mail address@hidden, Tel +44 (0) 1923 299718, Fax 299701

reply via email to

[Prev in Thread] Current Thread [Next in Thread]