Commit 27220172 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10700] Whether mpiexec is attached to a terminal does not make any difference

for our stdin strategy.  Remove that test.

No reviewer.
parent 2b1f35d8
......@@ -13,7 +13,7 @@ struct HYDT_dmxu_fns HYDT_dmxu_fns = { 0 };
static int got_sigttin = 0;
#if defined(SIGTTIN) && defined(HAVE_ISATTY)
#if defined(SIGTTIN)
static void signal_cb(int sig)
{
HYDU_FUNC_ENTER();
......@@ -25,7 +25,7 @@ static void signal_cb(int sig)
HYDU_FUNC_EXIT();
return;
}
#endif /* SIGTTIN and HAVE_ISATTY */
#endif /* SIGTTIN */
HYD_status HYDT_dmx_init(char **demux)
{
......@@ -228,25 +228,44 @@ HYD_status HYDT_dmxi_stdin_valid(int *out)
* that, we catch SIGTTIN and ignore it. But that causes the
* read() call to return an error (with errno == EINTR) when we
* are not attached to the terminal. */
#if defined(SIGTTIN) && defined(HAVE_ISATTY)
if (isatty(STDIN_FILENO)) {
status = HYDU_set_signal(SIGTTIN, signal_cb);
HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
}
#endif /* SIGTTIN and HAVE_ISATTY */
/*
* We need to allow for the following cases:
*
* 1. mpiexec -n 2 ./foo --> type something on the terminal
* Attached to terminal, and can read from stdin
*
* 2. mpiexec -n 2 ./foo &
* Attached to terminal, but cannot read from stdin
*
* 3. mpiexec -n 2 ./foo < bar
* Not attached to terminal, but can read from stdin
*
* 4. mpiexec -n 2 ./foo < /dev/null
* Not attached to terminal, and can read from stdin
*
* 5. mpiexec -n 2 ./foo < bar &
* Not attached to terminal, but can read from stdin
*
* 6. mpiexec -n 2 ./foo < /dev/null &
* Not attached to terminal, and can read from stdin
*/
#if defined(SIGTTIN)
status = HYDU_set_signal(SIGTTIN, signal_cb);
HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
#endif /* SIGTTIN */
ret = read(STDIN_FILENO, NULL, 0);
if (ret < 0 && errno == EINTR && got_sigttin)
*out = 0;
else
if (ret == 0)
*out = 1;
else
*out = 0;
#if defined(SIGTTIN) && defined(HAVE_ISATTY)
if (isatty(STDIN_FILENO)) {
status = HYDU_set_signal(SIGTTIN, SIG_IGN);
HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
}
#endif /* SIGTTIN and HAVE_ISATTY */
#if defined(SIGTTIN)
status = HYDU_set_signal(SIGTTIN, SIG_IGN);
HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
#endif /* SIGTTIN */
fn_exit:
HYDU_FUNC_EXIT();
......
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