Explorar o código

dpkg-deb: Use subproc functions instead of ad-hoc code

This makes cu_info_prepare call ohshite in case of error, but that's
fine as the normal unwinding will happen in that case.
Guillem Jover %!s(int64=16) %!d(string=hai) anos
pai
achega
3f355904aa
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      dpkg-deb/info.c

+ 3 - 4
dpkg-deb/info.c

@@ -49,20 +49,19 @@
 
 
 static void cu_info_prepare(int argc, void **argv) {
 static void cu_info_prepare(int argc, void **argv) {
   pid_t c1;
   pid_t c1;
-  int status;
   char *directory;
   char *directory;
   struct stat stab;
   struct stat stab;
 
 
   directory= (char*)(argv[0]);
   directory= (char*)(argv[0]);
   if (chdir("/")) { perror(_("failed to chdir to `/' for cleanup")); return; }
   if (chdir("/")) { perror(_("failed to chdir to `/' for cleanup")); return; }
   if (lstat(directory,&stab) && errno==ENOENT) return;
   if (lstat(directory,&stab) && errno==ENOENT) return;
-  if ((c1= fork()) == -1) { perror(_("failed to fork for cleanup")); return; }
+
+  c1 = subproc_fork();
   if (!c1) {
   if (!c1) {
     execlp(RM, "rm", "-rf", directory, NULL);
     execlp(RM, "rm", "-rf", directory, NULL);
     perror(_("failed to exec rm for cleanup")); _exit(1);
     perror(_("failed to exec rm for cleanup")); _exit(1);
   }
   }
-  if (waitpid(c1,&status,0) != c1) { perror(_("failed to wait for rm cleanup")); return; }
-  if (status) { fprintf(stderr,_("rm cleanup failed, code %d\n"),status); }
+  subproc_wait_check(c1, "rm cleanup", 0);
 } 
 } 
 
 
 static void info_prepare(const char *const **argvp,
 static void info_prepare(const char *const **argvp,