Skip to content
Snippets Groups Projects
Commit 4c0183f1 authored by Moe Jette's avatar Moe Jette
Browse files

minor improvements on Gerrit's salloc work

parent 8c19d7bb
No related branches found
No related tags found
No related merge requests found
...@@ -163,9 +163,17 @@ int main(int argc, char *argv[]) ...@@ -163,9 +163,17 @@ int main(int argc, char *argv[])
is_interactive = isatty(STDIN_FILENO); is_interactive = isatty(STDIN_FILENO);
if (is_interactive) { if (is_interactive) {
bool sent_msg = false;
/* Wait as long as we are running in the background */ /* Wait as long as we are running in the background */
while (tcgetpgrp(STDIN_FILENO) != (pid = getpgrp())) while (tcgetpgrp(STDIN_FILENO) != (pid = getpgrp())) {
if (!sent_msg) {
error("Waiting for %s to be placed in the "
"foreground", argv[0]);
sent_msg = true;
}
killpg(pid, SIGTTIN); killpg(pid, SIGTTIN);
}
/* /*
* Save tty attributes and reset at exit, in case a child * Save tty attributes and reset at exit, in case a child
* process died before properly resetting terminal. * process died before properly resetting terminal.
...@@ -769,14 +777,19 @@ static void _job_complete_handler(srun_job_complete_msg_t *comp) ...@@ -769,14 +777,19 @@ static void _job_complete_handler(srun_job_complete_msg_t *comp)
*/ */
if ((command_pid > -1) && if ((command_pid > -1) &&
(waitpid(command_pid, NULL, WNOHANG) == 0)) { (waitpid(command_pid, NULL, WNOHANG) == 0)) {
int signal = SIGTERM; int signal = 0;
#if !defined(HAVE_CRAY) #if defined(HAVE_CRAY)
signal = SIGTERM;
#else
if (opt.kill_command_signal_set) if (opt.kill_command_signal_set)
signal = opt.kill_command_signal; signal = opt.kill_command_signal;
#endif #endif
verbose("Sending signal %d to command \"%s\", pid %d", if (signal) {
signal, command_argv[0], command_pid); verbose("Sending signal %d to command \"%s\","
_forward_signal(signal); " pid %d",
signal, command_argv[0], command_pid);
_forward_signal(signal);
}
} }
} else { } else {
verbose("Job step %u.%u is finished.", verbose("Job step %u.%u is finished.",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment