Switch to unified view

a/src/utils/execmd.cpp b/src/utils/execmd.cpp
...
...
30
30
31
#if !defined(PUTENV_ARG_CONST)
31
#if !defined(PUTENV_ARG_CONST)
32
#include <string.h>
32
#include <string.h>
33
#endif
33
#endif
34
34
35
#include <list>
36
#include <vector>
35
#include <vector>
37
#include <string>
36
#include <string>
38
#include <sstream>
37
#include <sstream>
39
#include <iostream>
38
#include <iostream>
40
39
...
...
171
ExecCmd::~ExecCmd()
170
ExecCmd::~ExecCmd()
172
{
171
{
173
    ExecCmdRsrc(this);
172
    ExecCmdRsrc(this);
174
}
173
}
175
174
176
int ExecCmd::startExec(const string &cmd, const list<string>& args,
175
int ExecCmd::startExec(const string &cmd, const vector<string>& args,
177
               bool has_input, bool has_output)
176
               bool has_input, bool has_output)
178
{
177
{
179
    { // Debug and logging
178
    { // Debug and logging
180
    string command = cmd + " ";
179
    string command = cmd + " ";
181
    for (list<string>::const_iterator it = args.begin();it != args.end();
180
    for (vector<string>::const_iterator it = args.begin();it != args.end();
182
         it++) {
181
         it++) {
183
        command += "{" + *it + "} ";
182
        command += "{" + *it + "} ";
184
    }
183
    }
185
    LOGDEB(("ExecCmd::startExec: (%d|%d) %s\n", 
184
    LOGDEB(("ExecCmd::startExec: (%d|%d) %s\n", 
186
        has_input, has_output, command.c_str()));
185
        has_input, has_output, command.c_str()));
...
...
312
    string        *m_output;
311
    string        *m_output;
313
    ExecCmdAdvise *m_advise;
312
    ExecCmdAdvise *m_advise;
314
};
313
};
315
314
316
315
317
int ExecCmd::doexec(const string &cmd, const list<string>& args,
316
int ExecCmd::doexec(const string &cmd, const vector<string>& args,
318
            const string *input, string *output)
317
            const string *input, string *output)
319
{
318
{
320
319
321
    if (startExec(cmd, args, input != 0, output != 0) < 0) {
320
    if (startExec(cmd, args, input != 0, output != 0) < 0) {
322
    return -1;
321
    return -1;
...
...
503
    }
502
    }
504
}
503
}
505
504
506
// In child process. Set up pipes, environment, and exec command. 
505
// In child process. Set up pipes, environment, and exec command. 
507
// This must not return. exit() on error.
506
// This must not return. exit() on error.
508
void ExecCmd::dochild(const string &cmd, const list<string>& args,
507
void ExecCmd::dochild(const string &cmd, const vector<string>& args,
509
              bool has_input, bool has_output)
508
              bool has_input, bool has_output)
510
{
509
{
511
    // Start our own process group
510
    // Start our own process group
512
    if (setpgid(0, getpid())) {
511
    if (setpgid(0, getpid())) {
513
    LOGINFO(("ExecCmd::dochild: setpgid(0, %d) failed: errno %d\n",
512
    LOGINFO(("ExecCmd::dochild: setpgid(0, %d) failed: errno %d\n",
...
...
579
    }
578
    }
580
    
579
    
581
    // Fill up argv
580
    // Fill up argv
582
    argv[0] = cmd.c_str();
581
    argv[0] = cmd.c_str();
583
    int i = 1;
582
    int i = 1;
584
    list<string>::const_iterator it;
583
    vector<string>::const_iterator it;
585
    for (it = args.begin(); it != args.end(); it++) {
584
    for (it = args.begin(); it != args.end(); it++) {
586
    argv[i++] = it->c_str();
585
    argv[i++] = it->c_str();
587
    }
586
    }
588
    argv[i] = 0;
587
    argv[i] = 0;
589
588
...
...
682
#else // TEST
681
#else // TEST
683
#include <stdio.h>
682
#include <stdio.h>
684
#include <stdlib.h>
683
#include <stdlib.h>
685
#include <string>
684
#include <string>
686
#include <iostream>
685
#include <iostream>
687
#include <list>
686
#include <vector>
688
#include "debuglog.h"
687
#include "debuglog.h"
689
#include "cancelcheck.h"
688
#include "cancelcheck.h"
690
689
691
using namespace std;
690
using namespace std;
692
691
...
...
779
778
780
    if (argc < 1)
779
    if (argc < 1)
781
    Usage();
780
    Usage();
782
781
783
    string cmd = *argv++; argc--;
782
    string cmd = *argv++; argc--;
784
    list<string> l;
783
    vector<string> l;
785
    while (argc > 0) {
784
    while (argc > 0) {
786
    l.push_back(*argv++); argc--;
785
    l.push_back(*argv++); argc--;
787
    }
786
    }
788
    DebugLog::getdbl()->setloglevel(DEBDEB1);
787
    DebugLog::getdbl()->setloglevel(DEBDEB1);
789
    DebugLog::setfilename("stderr");
788
    DebugLog::setfilename("stderr");