#include "mount_utils.h"
#include "namespace.h"
#include "process_utils.h"
+#include "sync.h"
#include "syscall_wrappers.h"
#include "terminal.h"
#include "utils.h"
{
int ret_parent = -1;
struct lxc_epoll_descr descr = {};
- int ret, status;
+ int ret;
char *name, *lxcpath, *new_cwd;
int ipc_sockets[2];
pid_t attached_pid, pid, to_cleanup_pid;
}
/* Wait for the parent to have setup cgroups. */
- ret = lxc_read_nointr(ipc_sockets[1], &status, sizeof(status));
- if (ret != sizeof(status)) {
+ ret = sync_wait(ipc_sockets[1], ATTACH_SYNC_CGROUP);
+ if (ret) {
shutdown(ipc_sockets[1], SHUT_RDWR);
put_attach_context(ctx);
_exit(EXIT_FAILURE);
}
/* Let the child process know to go ahead. */
- status = 0;
- ret = lxc_write_nointr(ipc_sockets[0], &status, sizeof(status));
- if (ret != sizeof(status))
+ ret = sync_wake(ipc_sockets[0], ATTACH_SYNC_CGROUP);
+ if (ret)
goto close_mainloop;
TRACE("Told intermediate process to start initializing");
struct lxc_handler;
-enum {
+enum /* generic */ {
+ SYNC_ERROR = -1 /* Used to report errors from another process */
+};
+
+enum /* start */ {
START_SYNC_STARTUP = 0,
START_SYNC_CONFIGURE = 1,
START_SYNC_POST_CONFIGURE = 2,
START_SYNC_READY_START = 6,
START_SYNC_RESTART = 7,
START_SYNC_POST_RESTART = 8,
- SYNC_ERROR = -1 /* Used to report errors from another process */
+};
+
+enum /* attach */ {
+ ATTACH_SYNC_CGROUP = 0,
};
__hidden extern int lxc_sync_init(struct lxc_handler *handler);