colseonexec


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers colseonexec
# 1  
Old 03-08-2003
Question colseonexec

hi all..
can pls someone focus on the colseonexec() function call.. pls give an example whr in the application this will be used..
regards,
-neelam
# 2  
Old 03-08-2003
I hope that you understand that it is important to ensure that you don't leave files open across an exec() call. In this thread, someone was in trouble because they had not done this.

Now I think that a simple close() is the answer to this problem. For many years, that was the only solution in UNIX. And it's still the way I program. But look at this post. There are a lot of close() calls there. If I could make some of those files close themselves, I could shorten that program.

And there is a bigger problem... suppose that the exec() failed. I have
already closed some files. Now I might need to re-open them to report an error. And that may be impossible.

That is why the close on exec concept was developed. As I know it "close on exec" is a flag that can be set via open() or fcntl(). Until your question, I have never heard of closeonexec(). It is not in HP-UX nor Solaris. But google does find it. Apparently some versions of UNIX do have it. It is obviously just a wrapper around fcntl(). I'm not sure why that was done.
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question