Changeset 635


Ignore:
Timestamp:
Jan 5, 2016, 11:11:45 PM (10 years ago)
Author:
Yuri Dario
Message:

rpm: replace fork() with popen() when redirecting output. fixes ticket#143.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rpm/trunk/cliutils.c

    r634 r635  
    5656
    5757    char cmdline[16*1024];
    58     sprintf( cmdline, "sh -c %s", rpmcliPipeOutput);
     58    // place command line inside quotes to allow sh to execute all commands
     59    // itself (otherwise also cmd is involved)
     60    sprintf( cmdline, "sh -c \"%s\"", rpmcliPipeOutput);
    5961    // start child and redirect its input to us
    6062    pipeFD = popen( cmdline, "w");
     63    if (pipeFD == NULL) {
     64        fprintf(stderr, "creating a pipe for --pipe failed: %s\n", cmdline);
     65        return -1;
     66    }
    6167    // now redirect stdout to input handle
    6268    dup2( fileno(pipeFD), STDOUT_FILENO);
Note: See TracChangeset for help on using the changeset viewer.