Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling exit vs. _exit in the child process #1

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 3 comments
Closed

Calling exit vs. _exit in the child process #1

GoogleCodeExporter opened this issue Mar 19, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

The original user comment can be found here:
http://blog.famzah.net/2009/11/20/a-much-faster-popen-and-system-implementation-
for-linux/#comment-2078

The referred page (http://www.unixguide.net/unix/programming/1.1.3.shtml) says 
that _exit() must be used, instead of exit(), in situations like ours. All this 
sounds reasonable, but there are a few more things to consider:
  * we use exit() only for error termination -- testing will require that we manage to fail in the respective code blocks
  * we also use err() to exit on errors -- it must be tested whether it uses exit() or _exit(), and be replaced with a custom macro if exit() is used
  * this needs testing -- I've never had a test scenario where this has caused a problem

Resolution for now is 'do-nothing' until a practical test is shown, where 
exit() gives problems.






Original issue reported on code.google.com by ivan.zah...@gmail.com on 12 Mar 2011 at 11:38

@GoogleCodeExporter
Copy link
Author

Hi, I was the one posting on this issue on your blog.

I managed to get a crash when I compile popen_noshell.c in c++ (just a few 
malloc conversions are needed). 
See attached files for details, and
"g++ mytest.cpp popen_noshell.cpp -o mytest && ./mytest"
should lead to a segfault.

Note that if you compile popen_noshell.c as a pure C library and link it with 
mytests.cpp, there is no problem. Obviously there is no such thing as "call 
global object's destructors" in the C version of exit().

Original comment by devoud....@gmail.com on 13 Mar 2011 at 9:07

Attachments:

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Thank you for the attached examples. I've fixed the exit() vs. _exit() issue. 
It turned out that err() and errx() are using exit() too, so they needed to be 
wrapped.

Reference: Committed revision 5.

Original comment by ivan.zah...@gmail.com on 18 Mar 2011 at 9:40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant