On Wed, 07 Aug 2013 02:08:42 +0200, Jakub Klama wrote:
all writes to 'stdout' will be redirected to file, as stdout file
descriptor (usually 1 by convention) is now opened file.

Of course it's possible to archieve same thing without dup2(). POSIX
specification for open() says:

"The open() function shall return a file descriptor for the named
file that is the lowest file descriptor not currently open for that
process."

So one should close(fileno(stdout)) and then open() file, which
will return 1, as it's lowest free descriptor number, but probably
using dup2() makes this more explicit.

Jakub

_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel

Reply via email to