diff options
| author | Paul Eggert | 2018-11-23 00:33:37 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-11-23 00:33:50 -0800 |
| commit | 652dabfff6f99631f8f3d6c3a658f0b8895d48b0 (patch) | |
| tree | 6b69ebd557fa7975edafdd378e589305861af05d /lib-src | |
| parent | ef1f60301aabbcfc940bf8a826cd174ba2d0439c (diff) | |
| download | emacs-652dabfff6f99631f8f3d6c3a658f0b8895d48b0.tar.gz emacs-652dabfff6f99631f8f3d6c3a658f0b8895d48b0.zip | |
emacsclient: fix child exit when exec fails
* lib-src/emacsclient.c (start_daemon_and_retry_set_socket):
If the execvp of Emacs fails exit instead of having the child
run on and do the work of the parent. Coalesce duplicate code.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index b5ed2e0435a..9830eaecc6d 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -1484,13 +1484,6 @@ start_daemon_and_retry_set_socket (void) | |||
| 1484 | /* Try connecting, the daemon should have started by now. */ | 1484 | /* Try connecting, the daemon should have started by now. */ |
| 1485 | message (true, | 1485 | message (true, |
| 1486 | "Emacs daemon should have started, trying to connect again\n"); | 1486 | "Emacs daemon should have started, trying to connect again\n"); |
| 1487 | |||
| 1488 | if ((emacs_socket = set_socket (1)) == INVALID_SOCKET) | ||
| 1489 | { | ||
| 1490 | message (true, ("Error: Cannot connect " | ||
| 1491 | "even after starting the Emacs daemon\n")); | ||
| 1492 | exit (EXIT_FAILURE); | ||
| 1493 | } | ||
| 1494 | } | 1487 | } |
| 1495 | else if (dpid < 0) | 1488 | else if (dpid < 0) |
| 1496 | { | 1489 | { |
| @@ -1518,6 +1511,7 @@ start_daemon_and_retry_set_socket (void) | |||
| 1518 | # endif | 1511 | # endif |
| 1519 | execvp ("emacs", d_argv); | 1512 | execvp ("emacs", d_argv); |
| 1520 | message (true, "%s: error starting emacs daemon\n", progname); | 1513 | message (true, "%s: error starting emacs daemon\n", progname); |
| 1514 | exit (EXIT_FAILURE); | ||
| 1521 | } | 1515 | } |
| 1522 | # else /* WINDOWSNT */ | 1516 | # else /* WINDOWSNT */ |
| 1523 | DWORD wait_result; | 1517 | DWORD wait_result; |
| @@ -1583,13 +1577,15 @@ start_daemon_and_retry_set_socket (void) | |||
| 1583 | if (!w32_window_app ()) | 1577 | if (!w32_window_app ()) |
| 1584 | message (true, | 1578 | message (true, |
| 1585 | "Emacs daemon should have started, trying to connect again\n"); | 1579 | "Emacs daemon should have started, trying to connect again\n"); |
| 1586 | if ((emacs_socket = set_socket (1)) == INVALID_SOCKET) | 1580 | # endif /* WINDOWSNT */ |
| 1581 | |||
| 1582 | emacs_socket = set_socket (true); | ||
| 1583 | if (emacs_socket == INVALID_SOCKET) | ||
| 1587 | { | 1584 | { |
| 1588 | message (true, | 1585 | message (true, |
| 1589 | "Error: Cannot connect even after starting the Emacs daemon\n"); | 1586 | "Error: Cannot connect even after starting the Emacs daemon\n"); |
| 1590 | exit (EXIT_FAILURE); | 1587 | exit (EXIT_FAILURE); |
| 1591 | } | 1588 | } |
| 1592 | # endif /* WINDOWSNT */ | ||
| 1593 | } | 1589 | } |
| 1594 | #endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ | 1590 | #endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ |
| 1595 | 1591 | ||