|
82 | 82 | #include "src/util/pmix_environ.h" |
83 | 83 | #include "src/util/pmix_getcwd.h" |
84 | 84 | #include "src/util/pmix_show_help.h" |
| 85 | +#include "src/util/pmix_tty.h" |
85 | 86 |
|
86 | 87 | #include "src/class/pmix_pointer_array.h" |
87 | 88 | #include "src/runtime/prte_progress_threads.h" |
@@ -544,6 +545,69 @@ int prun_common(pmix_cli_result_t *results, |
544 | 545 | /* we want to be notified upon job completion */ |
545 | 546 | PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_NOTIFY_COMPLETION, &flag, PMIX_BOOL); |
546 | 547 |
|
| 548 | +#ifdef PMIX_SPAWN_PTY |
| 549 | + // see if they want to use a pty |
| 550 | + if (pmix_cmd_line_is_taken(results, PRTE_CLI_PTY)) { |
| 551 | + PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_SPAWN_PTY, NULL, PMIX_BOOL); |
| 552 | +#ifdef PMIX_PTY_TERMIO |
| 553 | + { |
| 554 | + // pass our termio settings |
| 555 | + struct termios terms; |
| 556 | + pmix_byte_object_t tbo; |
| 557 | + tbo.bytes = malloc(2 * sizeof(struct termios)); |
| 558 | + tbo.size = 2 * sizeof(struct termios); |
| 559 | + ret = pmix_gettermios(STDIN_FILENO, &terms); |
| 560 | + if (PMIX_SUCCESS != ret) { |
| 561 | + free(tbo.bytes); |
| 562 | + PMIX_INFO_LIST_RELEASE(jinfo); |
| 563 | + PRTE_UPDATE_EXIT_STATUS(ret); |
| 564 | + goto DONE; |
| 565 | + } |
| 566 | + memcpy(tbo.bytes, &terms, sizeof(struct termios)); |
| 567 | + memset(&terms, 0, sizeof(struct termios)); |
| 568 | + ret = pmix_gettermios(STDOUT_FILENO, &terms); |
| 569 | + if (PMIX_SUCCESS != ret) { |
| 570 | + free(tbo.bytes); |
| 571 | + PMIX_INFO_LIST_RELEASE(jinfo); |
| 572 | + PRTE_UPDATE_EXIT_STATUS(ret); |
| 573 | + goto DONE; |
| 574 | + } |
| 575 | + memcpy(tbo.bytes+sizeof(struct termios), &terms, sizeof(struct termios)); |
| 576 | + PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_PTY_TERMIO, &tbo, PMIX_BYTE_OBJECT); |
| 577 | + PMIX_BYTE_OBJECT_DESTRUCT(&tbo); |
| 578 | + } |
| 579 | +#endif |
| 580 | +#ifdef PMIX_PTY_WSIZE |
| 581 | + { |
| 582 | + // pass our window size |
| 583 | + struct winsize ws; |
| 584 | + pmix_byte_object_t tbo; |
| 585 | + tbo.bytes = malloc(2 * sizeof(struct winsize)); |
| 586 | + tbo.size = 2 * sizeof(struct winsize); |
| 587 | + ret = pmix_getwinsz(STDIN_FILENO, &ws); |
| 588 | + if (PMIX_SUCCESS != ret) { |
| 589 | + free(tbo.bytes); |
| 590 | + PMIX_INFO_LIST_RELEASE(jinfo); |
| 591 | + PRTE_UPDATE_EXIT_STATUS(ret); |
| 592 | + goto DONE; |
| 593 | + } |
| 594 | + memcpy(tbo.bytes, &ws, sizeof(struct winsize)); |
| 595 | + memset(&ws, 0, sizeof(struct winsize)); |
| 596 | + ret = pmix_getwinsz(STDOUT_FILENO, &ws); |
| 597 | + if (PMIX_SUCCESS != ret) { |
| 598 | + free(tbo.bytes); |
| 599 | + PMIX_INFO_LIST_RELEASE(jinfo); |
| 600 | + PRTE_UPDATE_EXIT_STATUS(ret); |
| 601 | + goto DONE; |
| 602 | + } |
| 603 | + memcpy(tbo.bytes+sizeof(struct winsize), &ws, sizeof(struct winsize)); |
| 604 | + PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_PTY_WSIZE, &tbo, PMIX_BYTE_OBJECT); |
| 605 | + PMIX_BYTE_OBJECT_DESTRUCT(&tbo); |
| 606 | + } |
| 607 | +#endif |
| 608 | + } |
| 609 | +#endif |
| 610 | + |
547 | 611 | /* pickup any relevant envars */ |
548 | 612 | ninfo = 4; |
549 | 613 | PMIX_INFO_CREATE(iptr, ninfo); |
|
0 commit comments