[ 
https://issues.apache.org/jira/browse/YARN-10019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16995107#comment-16995107
 ] 

Peter Bacsko commented on YARN-10019:
-------------------------------------

[~ebadger] no, we don't use these functions that you mentioned. Sometimes 
they're useful, someone might decide to use them for whatever reason in the 
future. Unlikely, but can happen.

My point is simply that from a system programming standpoint, {{_exit()}} is 
mostly the correct way of exiting from a failed child. It's just simply a good 
practice.

Let me copy paste some stuff from Michael Kerrisk: The Linux Programming 
Interface, section 25.4:

_"Instead of calling exit(), the child can call _exit(), so that it doesn’t 
flush stdio buffers. This technique exemplifies a more general principle: in an 
application that creates child processes that don’t exec new programs, 
typically only one ofthe processes (most often the parent) should terminate via 
exit(), while the other processes should terminate via _exit(). This ensures 
that only one process calls exit handlers and flushes stdio buffers, which is 
usually desirable."_

> container-executor: misc improvements in child processes and exec() calls
> -------------------------------------------------------------------------
>
>                 Key: YARN-10019
>                 URL: https://issues.apache.org/jira/browse/YARN-10019
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: nodemanager
>            Reporter: Peter Bacsko
>            Assignee: Peter Bacsko
>            Priority: Minor
>         Attachments: YARN-10019-001.patch, YARN-10019-002.patch
>
>
> There are a couple of improvements that we can do in container-executor 
> regarding how we exit from child processes and how we handle failed exec() 
> calls:
> 1. If we're in the child code path and we detect an erroneous condition, the 
> usual way is just simply call {{_exit()}}. Normal {{exit()}} occurs in the 
> parent. Calling {{_exit()}}  prevents flushing stdio buffers twice and any 
> cleanup logic registered with {{atexit()}} or {{on_exit()}} will run only 
> once.
> 2. There's code like {{if (execlp(script_file_dest, script_file_dest, NULL) 
> != 0) ...}} which is not necessary. Exec functions are not supposed to 
> return. If they do, it's definitely an error, so no need to check the return 
> value.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to