1
0
mirror of https://github.com/projectatomic/bubblewrap.git synced 2026-02-05 15:45:22 +01:00

utils: Add fork_intermediate_child() helper

This just forks and exits in the parent, continuing in the child.
This commit is contained in:
Alexander Larsson
2019-11-21 16:54:06 +01:00
parent d068ec2bfa
commit 4a7ecc630f
2 changed files with 15 additions and 0 deletions

13
utils.c
View File

@@ -80,6 +80,19 @@ die_oom (void)
exit (1);
}
/* Fork, return in child, exiting the previous parent */
void
fork_intermediate_child (void)
{
int pid = fork ();
if (pid == -1)
die_with_error ("Can't fork for --pidns");
/* Parent is an process not needed */
if (pid != 0)
exit (0);
}
void *
xmalloc (size_t size)
{

View File

@@ -54,6 +54,8 @@ void die (const char *format,
void die_oom (void) __attribute__((__noreturn__));
void die_unless_label_valid (const char *label);
void fork_intermediate_child (void);
void *xmalloc (size_t size);
void *xcalloc (size_t size);
void *xrealloc (void *ptr,