]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
-b/--background: check for error when fork()ing
authorDaniel Lenski <dlenski@gmail.com>
Mon, 16 Nov 2020 21:37:37 +0000 (13:37 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 16 Nov 2020 21:37:45 +0000 (13:37 -0800)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
main.c

diff --git a/main.c b/main.c
index b31b0571964934d2641de125cd12e8cb0efb8023..d08ff971c0a2ab9693738ddf144f53157959327f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1434,7 +1434,11 @@ static FILE *background_self(struct openconnect_info *vpninfo, char *pidfile) {
                        exit(1);
                }
        }
-       if ((pid = fork())) {
+       pid = fork();
+       if (pid == -1) {
+               vpn_perror(vpninfo, "Failed to continue in background\n");
+               exit(1);
+       } else if (pid > 0) {
                if (fp) {
                        fprintf(fp, "%d\n", pid);
                        fclose(fp);