Revision d85a58fe mnexec.c

View differences:

mnexec.c
23 23
#include <limits.h>
24 24
#include <sched.h>
25 25

  
26
#if !defined(VERSION)
27
#define VERSION "(devel)"
28
#endif
29

  
26 30
void usage(char *name) 
27 31
{
28
    printf("Execution utility for Mininet.\n"
29
           "usage: %s [-cdnp] [-a pid] [-g group] [-r rtprio] cmd args...\n"
30
           "-c: close all file descriptors except stdin/out/error\n"
31
           "-d: detach from tty by calling setsid()\n"
32
           "-n: run in new network namespace\n"
33
           "-p: print ^A + pid\n"
34
           "-a pid: attach to pid's network namespace\n"
35
           "-g group: add to cgroup\n"
36
           "-r rtprio: run with SCHED_RR (usually requires -g)\n",
32
    printf("Execution utility for Mininet\n\n"
33
           "Usage: %s [-cdnp] [-a pid] [-g group] [-r rtprio] cmd args...\n\n"
34
           "Options:\n"
35
           "  -c: close all file descriptors except stdin/out/error\n"
36
           "  -d: detach from tty by calling setsid()\n"
37
           "  -n: run in new network namespace\n"
38
           "  -p: print ^A + pid\n"
39
           "  -a pid: attach to pid's network namespace\n"
40
           "  -g group: add to cgroup\n"
41
           "  -r rtprio: run with SCHED_RR (usually requires -g)\n"
42
           "  -v: print version\n",
37 43
           name);
38 44
}
39 45

  
......
92 98
    int nsid;
93 99
    int pid;
94 100
    static struct sched_param sp;
95
    while ((c = getopt(argc, argv, "+cdnpa:g:r:")) != -1)
101
    while ((c = getopt(argc, argv, "+cdnpa:g:r:vh")) != -1)
96 102
        switch(c) {
97 103
        case 'c':
98 104
            /* close file descriptors except stdin/out/error */
......
152 158
                return 1;
153 159
            }
154 160
            break;
161
        case 'v':
162
            printf("%s\n", VERSION);
163
            exit(0);
164
        case 'h':
165
            usage(argv[0]);
166
            exit(0);
155 167
        default:
156 168
            usage(argv[0]);
157
            break;
169
            exit(1); 
158 170
        }
159 171

  
160 172
    if (optind < argc) {

Also available in: Unified diff