Commit 3ae0d5a7 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10701] Check for STDIN validity before any other sockets are opened. This is

to cover the case where an external script closed STDIN before calling
mpiexec.

No reviewer.
parent 27220172
...@@ -12,6 +12,7 @@ struct HYDT_dmxu_callback *HYDT_dmxu_cb_list = NULL; ...@@ -12,6 +12,7 @@ struct HYDT_dmxu_callback *HYDT_dmxu_cb_list = NULL;
struct HYDT_dmxu_fns HYDT_dmxu_fns = { 0 }; struct HYDT_dmxu_fns HYDT_dmxu_fns = { 0 };
static int got_sigttin = 0; static int got_sigttin = 0;
static int stdin_valid;
#if defined(SIGTTIN) #if defined(SIGTTIN)
static void signal_cb(int sig) static void signal_cb(int sig)
...@@ -63,6 +64,9 @@ HYD_status HYDT_dmx_init(char **demux) ...@@ -63,6 +64,9 @@ HYD_status HYDT_dmx_init(char **demux)
"cannot find an appropriate demux engine\n"); "cannot find an appropriate demux engine\n");
} }
status = HYDT_dmxu_fns.stdin_valid(&stdin_valid);
HYDU_ERR_POP(status, "error checking for stdin validity\n");
fn_exit: fn_exit:
HYDU_FUNC_EXIT(); HYDU_FUNC_EXIT();
return status; return status;
...@@ -277,5 +281,7 @@ HYD_status HYDT_dmxi_stdin_valid(int *out) ...@@ -277,5 +281,7 @@ HYD_status HYDT_dmxi_stdin_valid(int *out)
HYD_status HYDT_dmx_stdin_valid(int *out) HYD_status HYDT_dmx_stdin_valid(int *out)
{ {
return HYDT_dmxu_fns.stdin_valid(out); *out = stdin_valid;
return HYD_SUCCESS;
} }
...@@ -144,18 +144,13 @@ int main(int argc, char **argv) ...@@ -144,18 +144,13 @@ int main(int argc, char **argv)
status = HYDU_set_common_signals(signal_cb); status = HYDU_set_common_signals(signal_cb);
HYDU_ERR_POP(status, "unable to set signal\n"); HYDU_ERR_POP(status, "unable to set signal\n");
if (pipe(HYD_server_info.cmd_pipe) < 0)
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "pipe error\n");
status = HYDT_ftb_init(); status = HYDT_ftb_init();
HYDU_ERR_POP(status, "unable to initialize FTB\n"); HYDU_ERR_POP(status, "unable to initialize FTB\n");
/* Get user preferences */ /* Get user preferences */
status = HYD_uii_mpx_get_parameters(argv); status = HYD_uii_mpx_get_parameters(argv);
HYDU_ERR_POP(status, "error parsing parameters\n"); HYDU_ERR_POP(status, "error parsing parameters\n");
/* Now we initialize engines that require us to know user /* Now we initialize engines that require us to know user
* preferences */ * preferences */
#if HAVE_ALARM #if HAVE_ALARM
...@@ -163,6 +158,10 @@ int main(int argc, char **argv) ...@@ -163,6 +158,10 @@ int main(int argc, char **argv)
alarm(HYD_ui_mpich_info.ckpoint_int); alarm(HYD_ui_mpich_info.ckpoint_int);
#endif /* HAVE_ALARM */ #endif /* HAVE_ALARM */
/* The demux engine should be initialized before any sockets are
* created, since it checks for STDIN's validity. If STDIN was
* closed and we opened a socket that got the same fd as STDIN,
* this test will not be possible. */
status = HYDT_dmx_init(&HYD_server_info.user_global.demux); status = HYDT_dmx_init(&HYD_server_info.user_global.demux);
HYDU_ERR_POP(status, "unable to initialize the demux engine\n"); HYDU_ERR_POP(status, "unable to initialize the demux engine\n");
...@@ -318,6 +317,10 @@ int main(int argc, char **argv) ...@@ -318,6 +317,10 @@ int main(int argc, char **argv)
HYD_server_info.stdout_cb = HYD_uiu_stdout_cb; HYD_server_info.stdout_cb = HYD_uiu_stdout_cb;
HYD_server_info.stderr_cb = HYD_uiu_stderr_cb; HYD_server_info.stderr_cb = HYD_uiu_stderr_cb;
/* Create a pipe connection to wake up the process manager */
if (pipe(HYD_server_info.cmd_pipe) < 0)
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "pipe error\n");
/* Launch the processes */ /* Launch the processes */
status = HYD_pmci_launch_procs(); status = HYD_pmci_launch_procs();
HYDU_ERR_POP(status, "process manager returned error launching processes\n"); HYDU_ERR_POP(status, "process manager returned error launching processes\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment