Lines Matching +full:parent +full:- +full:child
1 // SPDX-License-Identifier: GPL-2.0+
3 * Helper functions to sync execution between parent and child processes.
12 * Information in a shared memory location for synchronization between child and
13 * parent.
16 /* The parent waits on this semaphore. */
19 /* If true, the child should give up as well. */
22 /* The child waits on this semaphore. */
25 /* If true, the parent should give up as well. */
34 (sync)->child_gave_up = true; \
45 (sync)->parent_gave_up = true; \
53 if ((x) == -1 && (errno == ENODEV || errno == EINVAL)) { \
54 (sync)->parent_gave_up = true; \
64 ret = sem_init(&sync->sem_parent, 1, 0); in init_child_sync()
70 ret = sem_init(&sync->sem_child, 1, 0); in init_child_sync()
81 sem_destroy(&sync->sem_parent); in destroy_child_sync()
82 sem_destroy(&sync->sem_child); in destroy_child_sync()
89 /* Wait until the child prods us. */ in wait_child()
90 ret = sem_wait(&sync->sem_parent); in wait_child()
92 perror("Error waiting for child"); in wait_child()
96 return sync->child_gave_up; in wait_child()
103 /* Unblock the child now. */ in prod_child()
104 ret = sem_post(&sync->sem_child); in prod_child()
106 perror("Error prodding child"); in prod_child()
117 /* Wait until the parent prods us. */ in wait_parent()
118 ret = sem_wait(&sync->sem_child); in wait_parent()
120 perror("Error waiting for parent"); in wait_parent()
124 return sync->parent_gave_up; in wait_parent()
131 /* Unblock the parent now. */ in prod_parent()
132 ret = sem_post(&sync->sem_parent); in prod_parent()
134 perror("Error prodding parent"); in prod_parent()