open() returns file descriptor zero

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

open() returns file descriptor zero

410 Views
gregkogut
Contributor I

I have a problem where open() on either conventional files or serial port device handles returns file descriptor zero.    This has the effect of overwriting the default descriptor for stdin and returning the same file descriptor for different files. 

This has occurred on two different OSes (Linaro and Yocto), and two different i.XM6 Q7 modules (iWave and Congatec). 

It is likely not a coding error.  The code works correctly on x86.

I have worked around the issue by calling dup() after each open() in order to manually make process-unique descriptors.  This results in correct program behavior.     But I'd like to understand the root cause.   Any ideas?

Labels (3)
0 Kudos
1 Reply

366 Views
LeonardoSandova
Specialist I

I have never heard something like that. What is the Kernel version? It would be good if you call your app with strace, so you can see all the system calls being before and after your open call, which may lead to something useful.

Leo

0 Kudos