open() returns file descriptor zero

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

open() returns file descriptor zero

619件の閲覧回数
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?

ラベル(3)
0 件の賞賛
返信
1 返信

575件の閲覧回数
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 件の賞賛
返信