Emit RPMCALLBACK_SCRIPT_ERROR notification on all scriptlet failures
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 3 Oct 2008 08:41:41 +0000 (11:41 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 3 Oct 2008 08:41:41 +0000 (11:41 +0300)
- previously the fork() failures and such would not be notified at all
- discard the not-so-useful differing exit codes (signal, exit status and
  whatnot) from commit 179ebc1745b51eb9821dd783c9df475ac539532d

lib/psm.c

index 2905d36..0afa47e 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -825,19 +825,13 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp,
     (void) psmWait(psm);
 
     if (psm->sq.reaped < 0) {
-       (void) rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR,
-                                stag, WTERMSIG(psm->sq.child));
        rpmlog(RPMLOG_ERR, _("%s scriptlet failed, waitpid(%d) rc %d: %s\n"),
                 sname, psm->sq.child, psm->sq.reaped, strerror(errno));
     } else if (!WIFEXITED(psm->sq.status) || WEXITSTATUS(psm->sq.status)) {
        if (WIFSIGNALED(psm->sq.status)) {
-           (void)rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR,
-                               stag, WTERMSIG(psm->sq.status));
            rpmlog(RPMLOG_ERR, _("%s scriptlet failed, signal %d\n"),
                    sname, WTERMSIG(psm->sq.status));
        } else {
-           (void) rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR,
-                                stag, WEXITSTATUS(psm->sq.status));
            rpmlog(RPMLOG_ERR, _("%s scriptlet failed, exit status %d\n"),
                   sname, WEXITSTATUS(psm->sq.status));
        }
@@ -849,6 +843,10 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp,
 exit:
     rpmtdFreeData(&prefixes);
 
+    if (rc != RPMRC_OK) {
+       (void) rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, stag, rc);
+    }
+
     if (out)
        xx = Fclose(out);       /* XXX dup'd STDOUT_FILENO */