#include <string.h>
#define _USE_BSD
#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
#include <signal.h>
+#include "win32compat.h"
/* Prototype definitions within this file. */
int no_command (char *cmd);
if (no_command("gzip --version > /dev/null 2>&1")) return fp;
save_fd = dup(0);
close(0); /* Redirect stdin for gzip. */
- dup(fileno(fp));
+ if (dup(fileno(fp)) < 0) {
+ perror("decompress_pipe");
+ return NULL;
+ }
fpipe = popen("gzip -q -d -f --stdout", "r");
if (fpipe == NULL) perror("uncompress_pipe");
close(0);
- dup(save_fd);
+ if (dup(save_fd) < 0) {
+ perror("decompress_pipe");
+ return NULL;
+ }
close(save_fd);
fclose(fp);
return fpipe;
fflush(NULL); /* Flush all buffered output before opening this pipe. */
save_fd = dup(1);
close(1); /* Redirect stdout for gzip. */
- dup(fileno(fp));
+ if (dup(fileno(fp)) < 0) {
+ perror("compress_pipe");
+ return NULL;
+ }
fpipe = popen("gzip -q -1 -c", "w");
if (fpipe == NULL) perror("compress_pipe");
close(1);
- dup(save_fd);
+ if (dup(save_fd) < 0) {
+ perror("compress_pipe");
+ return NULL;
+ }
return fpipe;
}