lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 properly indented] fix start_command() bug when stdin is closed
- Date: Tue, 26 Aug 2008 08:45:13 +0200
- From: Paolo Bonzini <bonzini@xxxxxxx>
- Subject: Re: [PATCH v2 properly indented] fix start_command() bug when stdin is closed
Hannes already answered everything, but now that I think more about it I
would actually consider putting it in main, just in case an important
file ends up in file descriptor = 2 and is corrupted by a call to die().
Just in case, this program shows that stderr always point to fd 2 even
if it is closed upon launch:
#include <stdio.h>
#include <fcntl.h>
int main()
{
int fd = open ("/dev/tty", O_WRONLY);
FILE *fp;
fp = fdopen (fd, "w");
fprintf (fp, "file descriptor %d\n", fd);
fflush (fp);
fprintf (stderr, "writing on stderr now\n");
}
bonzinip$ ./a.out 2<&-
file descriptor 2
writing on stderr now
bonzinip$
Patch coming in a moment.
Paolo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html