Skip to content

Commit

Permalink
Merge pull request #2531 from brauner/2018-08-16/minor_fixes
Browse files Browse the repository at this point in the history
state: s/sleep()/nanosleep()/
  • Loading branch information
stgraber committed Aug 16, 2018
2 parents 03eda56 + 746559f commit 1a1de30
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lxc/state.c
Expand Up @@ -100,8 +100,8 @@ static int fillwaitedstates(const char *strstates, lxc_state_t *states)
return 0;
}

extern int lxc_wait(const char *lxcname, const char *states, int timeout,
const char *lxcpath)
int lxc_wait(const char *lxcname, const char *states, int timeout,
const char *lxcpath)
{
int state = -1;
lxc_state_t s[MAX_STATE] = {0};
Expand All @@ -110,6 +110,11 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
return -1;

for (;;) {
struct timespec onesec = {
.tv_sec = 1,
.tv_nsec = 0,
};

state = lxc_cmd_sock_get_state(lxcname, lxcpath, s, timeout);
if (state >= 0)
break;
Expand All @@ -125,7 +130,7 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
if (timeout == 0)
return -1;

sleep(1);
(void)nanosleep(&onesec, NULL);
}

if (state < 0) {
Expand Down

0 comments on commit 1a1de30

Please sign in to comment.