]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
tidy 'create --command' failure handling 1076/head
authorEric Gillespie <epg@pretzelnet.org>
Mon, 22 Dec 2025 15:21:40 +0000 (09:21 -0600)
committerEric Gillespie <epg@pretzelnet.org>
Tue, 23 Dec 2025 17:15:21 +0000 (11:15 -0600)
Throw Exception in the case the child was STOPped or CONTinued.
Document that system(3) should handle those cases.

client/snapper/cmd-create.cc

index 40cde60d4d64aedd96e689955378f19970e1fca3..51f9e290a3ee22fa250c12a7d57fbb84405d682b 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <sys/wait.h>
 
+#include <cassert>
 #include <iostream>
 
 #include <client/snapper/cmd.h>
@@ -208,8 +209,13 @@ namespace snapper
                    if (exit_status != 0) {
                        SN_THROW(CommandException(exit_status));
                    }
-               } else {
+               } else if (WIFSIGNALED(status)) {
                    SN_THROW(Exception(sformat("%s killed with %d", command.c_str(), WTERMSIG(status))));
+               } else {
+                   // For system(3), only WIFEXITED or WIFSIGNALED should be possible.
+                   string error = sformat(_("%s got STOP or CONT signal and may still be running"),
+                                          command.c_str());
+                   SN_THROW(Exception(error));
                }
            } break;
        }