diff options
| author | Karl Heuer | 1996-01-09 23:40:33 +0000 |
|---|---|---|
| committer | Karl Heuer | 1996-01-09 23:40:33 +0000 |
| commit | 4a127b3b175c83d38b7cdb713e144965d75c091f (patch) | |
| tree | 0caa68f790c2365d3b473a5d9c4bbb7986f49855 /src/process.c | |
| parent | 11938f101889459ececb9ae4c533514f4fdb3e4e (diff) | |
| download | emacs-4a127b3b175c83d38b7cdb713e144965d75c091f.tar.gz emacs-4a127b3b175c83d38b7cdb713e144965d75c091f.zip | |
(create_process): Restore the signal state
after vfork whether it succeeds or not.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/process.c b/src/process.c index edff00b1c94..f7af9450c33 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1519,42 +1519,47 @@ create_process (process, new_argv, current_dir) | |||
| 1519 | environ = save_environ; | 1519 | environ = save_environ; |
| 1520 | } | 1520 | } |
| 1521 | 1521 | ||
| 1522 | /* This runs in the Emacs process. */ | ||
| 1522 | if (pid < 0) | 1523 | if (pid < 0) |
| 1523 | { | 1524 | { |
| 1524 | if (forkin >= 0) | 1525 | if (forkin >= 0) |
| 1525 | close (forkin); | 1526 | close (forkin); |
| 1526 | if (forkin != forkout && forkout >= 0) | 1527 | if (forkin != forkout && forkout >= 0) |
| 1527 | close (forkout); | 1528 | close (forkout); |
| 1528 | report_file_error ("Doing vfork", Qnil); | ||
| 1529 | } | 1529 | } |
| 1530 | 1530 | else | |
| 1531 | XSETFASTINT (XPROCESS (process)->pid, pid); | 1531 | { |
| 1532 | /* vfork succeeded. */ | ||
| 1533 | XSETFASTINT (XPROCESS (process)->pid, pid); | ||
| 1532 | 1534 | ||
| 1533 | #ifdef WINDOWSNT | 1535 | #ifdef WINDOWSNT |
| 1534 | register_child (pid, inchannel); | 1536 | register_child (pid, inchannel); |
| 1535 | #endif /* WINDOWSNT */ | 1537 | #endif /* WINDOWSNT */ |
| 1536 | 1538 | ||
| 1537 | /* If the subfork execv fails, and it exits, | 1539 | /* If the subfork execv fails, and it exits, |
| 1538 | this close hangs. I don't know why. | 1540 | this close hangs. I don't know why. |
| 1539 | So have an interrupt jar it loose. */ | 1541 | So have an interrupt jar it loose. */ |
| 1540 | stop_polling (); | 1542 | stop_polling (); |
| 1541 | signal (SIGALRM, create_process_1); | 1543 | signal (SIGALRM, create_process_1); |
| 1542 | alarm (1); | 1544 | alarm (1); |
| 1543 | XPROCESS (process)->subtty = Qnil; | 1545 | XPROCESS (process)->subtty = Qnil; |
| 1544 | if (forkin >= 0) | 1546 | if (forkin >= 0) |
| 1545 | close (forkin); | 1547 | close (forkin); |
| 1546 | alarm (0); | 1548 | alarm (0); |
| 1547 | start_polling (); | 1549 | start_polling (); |
| 1548 | if (forkin != forkout && forkout >= 0) | 1550 | if (forkin != forkout && forkout >= 0) |
| 1549 | close (forkout); | 1551 | close (forkout); |
| 1550 | 1552 | ||
| 1551 | #ifdef HAVE_PTYS | 1553 | #ifdef HAVE_PTYS |
| 1552 | if (pty_flag) | 1554 | if (pty_flag) |
| 1553 | XPROCESS (process)->tty_name = build_string (pty_name); | 1555 | XPROCESS (process)->tty_name = build_string (pty_name); |
| 1554 | else | 1556 | else |
| 1555 | #endif | 1557 | #endif |
| 1556 | XPROCESS (process)->tty_name = Qnil; | 1558 | XPROCESS (process)->tty_name = Qnil; |
| 1559 | } | ||
| 1557 | 1560 | ||
| 1561 | /* Restore the signal state whether vfork succeeded or not. | ||
| 1562 | (We will signal an error, below, if it failed.) */ | ||
| 1558 | #ifdef POSIX_SIGNALS | 1563 | #ifdef POSIX_SIGNALS |
| 1559 | #ifdef HAVE_VFORK | 1564 | #ifdef HAVE_VFORK |
| 1560 | /* Restore the parent's signal handlers. */ | 1565 | /* Restore the parent's signal handlers. */ |
| @@ -1585,6 +1590,10 @@ create_process (process, new_argv, current_dir) | |||
| 1585 | #endif /* not BSD4_1 */ | 1590 | #endif /* not BSD4_1 */ |
| 1586 | #endif /* SIGCHLD */ | 1591 | #endif /* SIGCHLD */ |
| 1587 | #endif /* !POSIX_SIGNALS */ | 1592 | #endif /* !POSIX_SIGNALS */ |
| 1593 | |||
| 1594 | /* Now generate the error if vfork failed. */ | ||
| 1595 | if (pid < 0) | ||
| 1596 | report_file_error ("Doing vfork", Qnil); | ||
| 1588 | } | 1597 | } |
| 1589 | #endif /* not VMS */ | 1598 | #endif /* not VMS */ |
| 1590 | 1599 | ||