~ubuntu-branches/ubuntu/precise/crossroads/precise

« back to all changes in this revision

Viewing changes to xr/sys/sysrun.cc

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2010-07-05 16:27:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100705162700-0g08tfav8ee9y51u
Tags: upstream-2.65
ImportĀ upstreamĀ versionĀ 2.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "sys"
 
2
#include "config/config"
 
3
 
 
4
int sysrun(string const &s) {
 
5
    int ret = system(s.c_str());
 
6
    if (ret == -1) {
 
7
        warnmsg(Mstr("Failed to start command: ") + s + "\n");
 
8
        return -1;
 
9
    }
 
10
    if (WIFEXITED(ret)) {
 
11
        int stat = WEXITSTATUS(ret);
 
12
        if (stat)
 
13
            warnmsg(Mstr("Command" ) + s +
 
14
                    Mstr(" exited with status ") + Mstr(stat) + "\n");
 
15
        else
 
16
            msg(Mstr("Command ") + s +
 
17
                Mstr(" terminated normally.\n"));
 
18
        return stat;
 
19
    }
 
20
    warnmsg(Mstr("Command ") + s + Mstr(" failed miserably!\n"));
 
21
    return ret;
 
22
}