+
+int
+gz_close(int gunzip_pid)
+{
+ int status;
+ int ret;
+
+ if (waitpid(gunzip_pid, &status, 0) == -1) {
+ perror_msg("waitpid");
+ return -1;
+ }
+
+ if (WIFSIGNALED(status)) {
+ error_msg("Unzip process killed by signal %d.\n",
+ WTERMSIG(status));
+ return -1;
+ }
+
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ error_msg("Your system is broken: got status %d from waitpid.\n",
+ status);
+ return -1;
+ }
+
+ if ((ret = WEXITSTATUS(status))) {
+ error_msg("Unzip process failed with return code %d.\n",
+ ret);
+ return -1;
+ }
+
+ return 0;
+}