Changeset 1009
- Timestamp:
- Feb 21, 2017, 1:50:18 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rpm/trunk/cliutils.c
r639 r1009 15 15 16 16 static pid_t pipeChild = 0; 17 #ifdef __KLIBC__18 static FILE* pipeFD = NULL;19 #endif20 17 21 18 RPM_GNUC_NORETURN … … 53 50 int p[2]; 54 51 55 #ifdef __KLIBC__56 57 char cmdline[16*1024];58 // place command line inside quotes to allow sh to execute all commands59 // itself (otherwise also cmd is involved)60 sprintf( cmdline, "sh -c \"%s\"", rpmcliPipeOutput);61 // start child and redirect its input to us62 pipeFD = popen( cmdline, "w");63 if (pipeFD == NULL) {64 fprintf(stderr, "creating a pipe for --pipe failed: %s\n", cmdline);65 return -1;66 }67 // now redirect stdout to input handle68 dup2( fileno(pipeFD), STDOUT_FILENO);69 70 #else71 72 52 if (pipe(p) < 0) { 73 53 fprintf(stderr, _("creating a pipe for --pipe failed: %m\n")); … … 88 68 (void) dup2(p[1], STDOUT_FILENO); 89 69 (void) close(p[1]); 90 #endif91 92 70 return 0; 93 71 } … … 96 74 { 97 75 int rc = 0; 98 99 #ifdef __KLIBC__100 101 if (pipeFD) {102 // close stdout to allow child to end103 (void) fclose(stdout);104 // wait child end and query exit code105 int status = pclose(pipeFD);106 pipeFD = NULL;107 if (!WIFEXITED(status) || WEXITSTATUS(status))108 rc = 1;109 }110 111 #else112 76 if (pipeChild) { 113 77 int status; … … 122 86 rc = 1; 123 87 } 124 #endif125 126 88 return rc; 127 89 }
Note:
See TracChangeset
for help on using the changeset viewer.