SHA256
1
0
forked from pool/schily
schily/schily-2018-05-25_star_detect_gzip_failures.patch

96 lines
2.6 KiB
Diff

From: Kristyna Streitova <kstreitova@suse.com>
Date: Wed, 06 Jun 2018 14:51:57 +0000
References: http://bugzilla.opensuse.org/858660
X-Upstream: PATCH-FIX-UPSTREAM
detect gzip failures
Index: schily-2018-05-25/star/buffer.c
===================================================================
--- schily-2018-05-25.orig/star/buffer.c
+++ schily-2018-05-25/star/buffer.c
@@ -1804,6 +1804,10 @@ checkerrs()
errmsgno(EX_BAD, "Problems with restore database.\n");
return (TRUE);
}
+ if (xstats.s_comprerrs > 0) {
+ errmsgno(EX_BAD, "Compress program returned error[%d].\n", xstats.s_comprerrs);
+ return (TRUE);
+ }
return (FALSE);
}
@@ -1879,6 +1883,16 @@ die(err)
excomerrno(err, "Cannot recover from error - exiting.\n");
}
+void sigchld_handler(int sig)
+{
+ int status;
+ pid_t pid;
+ while ((pid = wait4(compresspid, &status, 0, NULL)) > 0) {
+ if (pid == compresspid)
+ xstats.s_comprerrs = WEXITSTATUS(status);
+ }
+
+}
/*
* Quick hack to implement a -z flag. May be changed soon.
*/
@@ -1894,6 +1908,8 @@ compressopen()
int mypid;
char *zip_prog = "gzip";
+ compresspid = 0;
+
if (compress_prg)
zip_prog = compress_prg;
else if (bzflag)
@@ -1957,6 +1973,7 @@ compressopen()
#else
if (fpipe(pp) == 0)
comerr("Compress pipe failed\n");
+ signal(SIGCHLD, sigchld_handler);
mypid = fork();
if (mypid < 0)
comerr("Compress fork failed\n");
@@ -1986,7 +2003,10 @@ compressopen()
fexecl(zip_prog, tarf, pp[1], null, zip_prog, "-d", (char *)NULL);
errmsg("Compress: exec of '%s' failed\n", zip_prog);
_exit(-1);
+ } else {
+ compresspid = mypid;
}
+
fclose(tarf);
if (cflag) {
tarf = pp[1];
Index: schily-2018-05-25/star/star.c
===================================================================
--- schily-2018-05-25.orig/star/star.c
+++ schily-2018-05-25/star/star.c
@@ -117,6 +117,7 @@ char strvers[] = "1.5.4"; /* The pure v
char *vers; /* the full version string */
struct star_stats xstats; /* for printing statistics */
+pid_t compresspid = 0;
extern BOOL havepat; /* Pattern matching in use */
Index: schily-2018-05-25/star/star.h
===================================================================
--- schily-2018-05-25.orig/star/star.h
+++ schily-2018-05-25/star/star.h
@@ -870,9 +870,11 @@ struct star_stats {
int s_setxattr; /* set xattr for file failed */
#endif
int s_restore; /* other incremental restore specific */
+ int s_comprerrs; /* errors of compress-subprogram */
};
extern struct star_stats xstats;
+extern pid_t compresspid; /* pid of compress-subprogram child */
#include <schily/param.h>