>Casper.Dik at Sun.COM wrote:
>>> Hi!
>>>
>>> ----
>>>
>>> Is there a way to detect whether a fd refers to "/dev/null" based on the
>>> return values of |stat()| ?
>> 
>> Sure, stat("/dev/null") and compare the fields:
>> 
>>      st_mode (the type of the file, must be a char device)
>> 
>>      st_rdev (the major, minor of the device), note: "st_*r*dev", not
>>              st_dev.
>
>Remember that /dev/null is a symlink though.  So Ideally do an open(2) [ 
>and *don't* specify O_NOFOLLOW] then fstat it.

I said "stat"; stat works, lstat does not.

Casper

Reply via email to