d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen#ifndef CHILD_WAIT_H
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen#define CHILD_WAIT_H
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenstruct child_wait_status {
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen struct child_wait *wait;
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen pid_t pid;
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen int status;
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen};
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainentypedef void child_wait_callback_t(const struct child_wait_status *status,
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen void *context);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenstruct child_wait *
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenchild_wait_new_with_pid(pid_t pid, child_wait_callback_t *callback,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen void *context) ATTR_NULL(3);
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen#define child_wait_new_with_pid(pid, callback, context) \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen child_wait_new_with_pid(pid + \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen CALLBACK_TYPECHECK(callback, void (*)( \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen const struct child_wait_status *status, typeof(context))), \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen (child_wait_callback_t *)callback, context)
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen#define child_wait_new(callback, context) \
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen child_wait_new_with_pid((pid_t)-1, callback, context)
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenvoid child_wait_free(struct child_wait **wait);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenvoid child_wait_add_pid(struct child_wait *wait, pid_t pid);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenvoid child_wait_remove_pid(struct child_wait *wait, pid_t pid);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
0043fea12a75cf8fcf2892673106844376da8e76Stephan Boschvoid child_wait_switch_ioloop(void);
0043fea12a75cf8fcf2892673106844376da8e76Stephan Bosch
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenvoid child_wait_init(void);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainenvoid child_wait_deinit(void);
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen
d10036d32eac25c861f9075ade2c007f5524b81eTimo Sirainen#endif