8 #include <rpm/rpmlog.h>
9 #include <rpm/rpmlib.h>
10 #include <rpm/rpmfileutil.h>
11 #include <rpm/rpmmacro.h>
12 #include <rpm/rpmcli.h>
16 static pid_t pipeChild = 0;
19 void argerror(const char * desc)
21 fprintf(stderr, _("%s: %s\n"), __progname, desc);
25 static void printVersion(FILE * fp)
27 fprintf(fp, _("RPM version %s\n"), rpmEVR);
30 static void printBanner(FILE * fp)
32 fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
33 fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
36 void printUsage(poptContext con, FILE * fp, int flags)
43 poptPrintHelp(con, fp, flags);
45 poptPrintUsage(con, fp, flags);
53 fprintf(stderr, _("creating a pipe for --pipe failed: %m\n"));
57 if (!(pipeChild = fork())) {
58 (void) signal(SIGPIPE, SIG_DFL);
60 (void) dup2(p[0], STDIN_FILENO);
62 (void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
63 fprintf(stderr, _("exec failed\n"));
68 (void) dup2(p[1], STDOUT_FILENO);
80 (void) fclose(stdout);
82 reaped = waitpid(pipeChild, &status, 0);
83 } while (reaped == -1 && errno == EINTR);
85 if (reaped == -1 || !WIFEXITED(status) || WEXITSTATUS(status))