Re: [PATCH 2/5] daemon: if one of the standard fds is missing open it to /dev/null
- From
- Morten Welinder <mwelinder@gmail.com>
- Date
- Jul 13, 2006, 15:37 UTC
- Message-ID
- <118833cc0607130837u30c58d53lc785f56d45ef970c@mail.gmail.com>
- In-Reply-To
- <E1G0znB-0002IO-61@moooo.ath.cx>
Show 5 quoted lines
> + if (devnull == -1 &&
> + (devnull = open("/dev/null", O_RDWR, 0)) == -1)
> + die("open /dev/null failed: %s", strerror(errno));
> + if (dup2(devnull, i) != i)
> + die("dup2 failed: %s", strerror(errno));"die" probably won't work well at this point.
Should git (and most other programs) do something like this in general? fprintf will happily write to fd=2 regardless of whether that is some critical file you opened.
Morten