Parcourir la source

libdpkg: Create a new error context in subproc_fork

Instead of changing the current error display handler and pushing a
cleanup handler that exits immediately to avoid calling previously
set cleanup handlers, just push a new error context which will work
as a cleanup barrier. This also is a more natural way of using the
current interface.
Guillem Jover il y a 15 ans
Parent
commit
29f4ab41c9
1 fichiers modifiés avec 3 ajouts et 10 suppressions
  1. 3 10
      lib/dpkg/subproc.c

+ 3 - 10
lib/dpkg/subproc.c

@@ -77,14 +77,6 @@ print_subproc_error(const char *emsg, const char *contextstring)
 	fprintf(stderr, _("%s (subprocess): %s\n"), thisname, emsg);
 }
 
-static void DPKG_ATTR_NORET
-subproc_fork_cleanup(int argc, void **argv)
-{
-	/* Don't do the other cleanups, because they'll be done by/in the
-	 * parent process. */
-	exit(2);
-}
-
 pid_t
 subproc_fork(void)
 {
@@ -98,8 +90,9 @@ subproc_fork(void)
 	if (r > 0)
 		return r;
 
-	push_cleanup(subproc_fork_cleanup, ~0, NULL, 0, 0);
-	set_error_display(print_subproc_error, NULL);
+	/* Push a new error context, so that we don't do the other cleanups,
+	 * because they'll be done by/in the parent process. */
+	push_error_context_func(catch_fatal_error, print_subproc_error, NULL);
 
 	return r;
 }