|
29 | 29 | * |
30 | 30 | * Portions of this software are Copyright (c) 2011 Univa Corporation |
31 | 31 | * |
32 | | - * Portions of this software are Copyright (c) 2023-2026 HPC-Gridware GmbH |
| 32 | + * Portions of this software are Copyright (c) 2026 HPC-Gridware GmbH |
33 | 33 | * |
34 | 34 | ************************************************************************/ |
35 | 35 | /*___INFO__MARK_END__*/ |
@@ -301,19 +301,19 @@ static int wait_until_parent_has_registered_to_server(int fd_pipe_to_child[]) |
301 | 301 | SIGIGNORE(SIGWINCH); |
302 | 302 |
|
303 | 303 | /* close parents end of our copy of the pipe */ |
304 | | - shepherd_trace("child: closing parents end of the pipe_to_child"); |
| 304 | + shepherd_trace("child: closing parent side ends of pipes: %d", fd_pipe_to_child[1]); |
305 | 305 | close(fd_pipe_to_child[1]); |
306 | 306 | fd_pipe_to_child[1] = -1; |
307 | 307 |
|
308 | 308 | /* wait until parent has registered at the server */ |
309 | | - shepherd_trace("child: trying to read from parent through the pipe_to_child"); |
| 309 | + shepherd_trace("child: trying to read from parent through the pipe_to_child[0] = %d", fd_pipe_to_child[0]); |
310 | 310 | ret = read(fd_pipe_to_child[0], tmpbuf, 11); |
311 | 311 | if (ret <= 0) { |
312 | | - shepherd_trace("child: error communicating with parent: %d, %s", |
313 | | - errno, strerror(errno)); |
| 312 | + shepherd_trace("child: error communicating with parent: %d, %s", errno, strerror(errno)); |
314 | 313 | ret = -1; |
315 | 314 | } else { |
316 | 315 | /* close other side of our copy of the pipe */ |
| 316 | + shepherd_trace("child: closing child side ends of pipes: %d", fd_pipe_to_child[0]); |
317 | 317 | close(fd_pipe_to_child[0]); |
318 | 318 | fd_pipe_to_child[0] = -1; |
319 | 319 | shepherd_trace("child: parent sent us '%s'", tmpbuf); |
@@ -699,8 +699,8 @@ int main(int argc, char **argv) |
699 | 699 | shepherd_error(1, "can't read cwd - getcwd failed: %s", strerror(errno)); |
700 | 700 | } |
701 | 701 |
|
702 | | - if (argc >= 2 && !strcmp("-bg", argv[1])) { |
703 | | - foreground = 0; /* no output to stderr */ |
| 702 | + if (argc >= 2 && strcmp("-bg", argv[1]) == 0) { |
| 703 | + foreground = false; // no shepherd_trace() output to stdout |
704 | 704 | } |
705 | 705 |
|
706 | 706 | set_shepherd_signal_mask(); |
@@ -1128,8 +1128,14 @@ static int start_child( |
1128 | 1128 | } |
1129 | 1129 | } |
1130 | 1130 |
|
1131 | | - if (pid==0) { /* child */ |
| 1131 | + if (pid == 0) { // child |
1132 | 1132 | if (g_new_interactive_job_support && is_interactive) { |
| 1133 | + // When we are running a builtin interactive job, in foreground mode shepherd_trace() would |
| 1134 | + // print the messages to stdout which is redirected to a pipe to the shepherd parent. |
| 1135 | + // The output would then be forwarded to the qrsh client. |
| 1136 | + // Disable foreground mode. |
| 1137 | + foreground = false; |
| 1138 | + |
1133 | 1139 | // Why do we wait until the connection to qrsh is up? |
1134 | 1140 | // To avoid starting the job when the qrsh client has terminated in the meantime? |
1135 | 1141 | ret = wait_until_parent_has_registered_to_server(fd_pipe_to_child); |
@@ -1383,9 +1389,7 @@ static int start_child( |
1383 | 1389 | } |
1384 | 1390 |
|
1385 | 1391 | /******* write usage to file "usage" ************/ |
1386 | | - shepherd_write_usage_file(wait_status, exit_status, |
1387 | | - child_signal, start_time, |
1388 | | - end_time, &rusage); |
| 1392 | + shepherd_write_usage_file(wait_status, exit_status, child_signal, start_time, end_time, &rusage); |
1389 | 1393 |
|
1390 | 1394 | /* this is SEMPA stuff */ |
1391 | 1395 | notify_tasker(exit_status); |
@@ -1528,9 +1532,6 @@ dstring *dstr_error /* OUT: error message - if any */ |
1528 | 1532 | int remote_port = 0; |
1529 | 1533 | int exit_status = -1; |
1530 | 1534 |
|
1531 | | - /* close child's end of the pipe */ |
1532 | | - shepherd_trace("parent: closing child's end of the pipe"); |
1533 | | - |
1534 | 1535 | /* read destination host and port from config */ |
1535 | 1536 | ret = get_remote_host_and_port_from_config(&remote_host, &remote_port, dstr_error); |
1536 | 1537 | if (ret != 0 || remote_host == nullptr || remote_port == 0) { |
@@ -2764,6 +2765,8 @@ static int start_async_command(const char *descr, char *cmd) |
2764 | 2765 | if ((pid = fork()) == -1) { |
2765 | 2766 | shepherd_trace("can't fork for starting %s command", descr); |
2766 | 2767 | } else if (pid == 0) { |
| 2768 | + foreground = false; |
| 2769 | + |
2767 | 2770 | int use_qsub_gid; |
2768 | 2771 | gid_t gid; |
2769 | 2772 | char *tmp_str; |
@@ -2808,8 +2811,6 @@ static int start_async_command(const char *descr, char *cmd) |
2808 | 2811 | exit(1); |
2809 | 2812 | } |
2810 | 2813 |
|
2811 | | - foreground = 0; |
2812 | | - |
2813 | 2814 | cwd = get_conf_val("cwd"); |
2814 | 2815 | if (sge_chdir(cwd)) { |
2815 | 2816 | shepherd_trace("%s: can't chdir to %s", descr, cwd); |
|
0 commit comments