+ /* --- Run the local precommit check script --- */
+
+ {
+ pid_t kid;
+ struct sigaction sa, sa_int, sa_quit;
+ int status;
+
+ /* --- Make sure I can trap the child's death --- */
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction(SIGINT, &sa, &sa_int) || sigaction(SIGQUIT, &sa, &sa_quit))
+ die(1, "couldn't set signal dispositions: %s", strerror(errno));
+
+ /* --- Spawn off a child process --- */
+
+ fflush(0);
+ kid = fork();
+ if (kid < 0)
+ die(1, "error from fork: %s", strerror(errno));
+ if (kid == 0) {
+ sym_table t;
+
+ /* --- Re-enable signals --- */
+
+ sigaction(SIGINT, &sa_int, 0);
+ sigaction(SIGQUIT, &sa_quit, 0);
+
+ /* --- Set up the environment --- */
+
+ sym_create(&t);
+ env_import(&t, environ);
+ env_put(&t, "SW_PACKAGE", sw.package);
+ env_put(&t, "SW_VERSION", sw.version);
+ env_put(&t, "SW_MAINTAINER", sw.maintainer);
+ env_put(&t, "SW_DATE", sw.date);
+ env_put(&t, "SW_ARCHLIST", sw.arch);
+ env_put(&t, "SW_PREFIX", sw.prefix);
+ environ = env_export(&t);
+
+ /* --- Run the commit check script --- */
+
+ execl(PREFIX "/share/sw-precommit", "sw-precommit",
+ sw.package, (void *)0);
+ if (errno == ENOENT)
+ _exit(0);
+ die(1, "couldn't run " PREFIX "/share/sw-precommit: %s",
+ strerror(errno));
+ }
+
+ /* --- Wait for the child to finish --- */
+
+ if (waitpid(kid, &status, 0) < 0)
+ die(1, "error waiting for child: %s", strerror(errno));
+ if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0))
+ die(1, "sw-precommit failed");
+ sigaction(SIGINT, &sa_int, 0);
+ sigaction(SIGQUIT, &sa_quit, 0);
+ }
+