Changeset 634
- Timestamp:
- Jan 5, 2016, 10:56:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rpm/trunk/cliutils.c
r595 r634 15 15 16 16 static pid_t pipeChild = 0; 17 #ifdef __KLIBC__ 18 static FILE* pipeFD = NULL; 19 #endif 17 20 18 21 RPM_GNUC_NORETURN … … 50 53 int p[2]; 51 54 55 #ifdef __KLIBC__ 56 57 char cmdline[16*1024]; 58 sprintf( cmdline, "sh -c %s", rpmcliPipeOutput); 59 // start child and redirect its input to us 60 pipeFD = popen( cmdline, "w"); 61 // now redirect stdout to input handle 62 dup2( fileno(pipeFD), STDOUT_FILENO); 63 64 #else 65 52 66 if (pipe(p) < 0) { 53 67 fprintf(stderr, _("creating a pipe for --pipe failed: %m\n")); … … 68 82 (void) dup2(p[1], STDOUT_FILENO); 69 83 (void) close(p[1]); 84 #endif 85 70 86 return 0; 71 87 } … … 74 90 { 75 91 int rc = 0; 92 93 #ifdef __KLIBC__ 94 95 // close stdout to allow child to end 96 (void) fclose(stdout); 97 // wait child end and query exit code 98 int status = pclose(pipeFD); 99 pipeFD = NULL; 100 if (!WIFEXITED(status) || WEXITSTATUS(status)) 101 rc = 1; 102 103 #else 76 104 if (pipeChild) { 77 105 int status; … … 86 114 rc = 1; 87 115 } 116 #endif 117 88 118 return rc; 89 119 }
Note:
See TracChangeset
for help on using the changeset viewer.