~ubuntu-branches/ubuntu/quantal/lxc/quantal-201208232243

« back to all changes in this revision

Viewing changes to src/lxc/lxc_wait.c

  • Committer: Serge Hallyn
  • Date: 2012-07-26 17:58:42 UTC
  • Revision ID: serge@serge-laptop-20120726175842-uvip2ssxtfakmhpq
[ Serge Hallyn ]
* lxc.lxc-net.upstart: replace the check for USE_LXC_BRIDGE (which could be
  changed from true to false after starting lxc-net) with one for the
  existence /var/run/lxc.  (LP: #1019290)
* 0095-lxc-clone-change-uuid-on-xfs.patch: give each cloned xfs-backed
  lvm partition a unique uuid so they can be mounted simultaneously.
  (LP: #1013549)
* 0096-lxc-wait-add-timeout.patch: patch submitted upstream to add a timeout
  option to lxc-wait.  (LP: #1020179)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <string.h>
25
25
#include <libgen.h>
26
26
#include <unistd.h>
 
27
#include <stdlib.h>
 
28
#include <signal.h>
27
29
#include <sys/types.h>
28
30
 
29
31
#include <lxc/lxc.h>
46
48
{
47
49
        switch (c) {
48
50
        case 's': args->states = optarg; break;
 
51
        case 't': args->timeout = atol(optarg); break;
49
52
        }
50
53
        return 0;
51
54
}
52
55
 
53
56
static const struct option my_longopts[] = {
54
57
        {"state", required_argument, 0, 's'},
 
58
        {"timeout", required_argument, 0, 't'},
55
59
        LXC_COMMON_OPTIONS
56
60
};
57
61
 
66
70
  -n, --name=NAME   NAME for name of the container\n\
67
71
  -s, --state=STATE ORed states to wait for\n\
68
72
                    STOPPED, STARTING, RUNNING, STOPPING,\n\
69
 
                    ABORTING, FREEZING, FROZEN\n",
 
73
                    ABORTING, FREEZING, FROZEN\n\
 
74
  -t, --timeout=TMO Seconds to wait for state changes\n",
70
75
        .options  = my_longopts,
71
76
        .parser   = my_parser,
72
77
        .checker  = my_checker,
91
96
        return 0;
92
97
}
93
98
 
 
99
static void timeout_handler(int signal)
 
100
{
 
101
        exit(-1);
 
102
}
 
103
 
94
104
int main(int argc, char *argv[])
95
105
{
96
106
        struct lxc_msg msg;
124
134
                goto out_close;
125
135
        }
126
136
 
 
137
        signal(SIGALRM, timeout_handler);
 
138
        alarm(my_args.timeout);
 
139
 
127
140
        for (;;) {
128
141
                if (lxc_monitor_read(fd, &msg) < 0)
129
142
                        goto out_close;
140
153
                        }
141
154
 
142
155
                        if (s[msg.value]) {
 
156
                                alarm(0);
143
157
                                ret = 0;
144
158
                                goto out_close;
145
159
                        }