Vinod Kumar Vavilapalli resolved YARN-100.
    Resolution: Later

LOGFILE and ERRORFILE were always this way, and it has worked out for long 

I don't see requests to change them to point them to other files, going to 
close it as later for now. Please revert back if you disagree.

> container-executor should deal with stdout, stderr better
> ---------------------------------------------------------
>                 Key: YARN-100
>                 URL: https://issues.apache.org/jira/browse/YARN-100
>             Project: Hadoop YARN
>          Issue Type: Improvement
>          Components: nodemanager
>    Affects Versions: 2.0.1-alpha
>            Reporter: Colin Patrick McCabe
>            Priority: Minor
> container-executor.c contains the following code:
> {code}
>   fclose(stdin);
>   fflush(LOGFILE);
>   if (LOGFILE != stdout) {
>     fclose(stdout);
>   }
>   if (ERRORFILE != stderr) {
>     fclose(stderr);
>   }
>   if (chdir(primary_app_dir) != 0) {
>     fprintf(LOGFILE, "Failed to chdir to app dir - %s\n", strerror(errno));
>     return -1;
>   }
>   execvp(args[0], args);
> {code}
> Whenever you open a new file descriptor, its number is the lowest available 
> number.  So if {{stdout}} (fd number 1) has been closed, and you do 
> open("/my/important/file"), you'll get assigned file descriptor 1.  This 
> means that any printf statements in the program will be now printing to 
> /my/important/file.  Oops!
> The correct way to get rid of stdin, stdout, or stderr is not to close them, 
> but to make them point to /dev/null.  {{dup2}} can be used for this purpose.
> It looks like LOGFILE and ERRORFILE are always set to stdout and stderr at 
> the moment.  However, this is a latent bug that should be fixed in case these 
> are ever made configurable (which seems to have been the intent).

This message was sent by Atlassian JIRA

Reply via email to