raw_syscalls: add lxc_raw_getpid()

parent 38e5c2db
...@@ -342,13 +342,16 @@ if ENABLE_COMMANDS ...@@ -342,13 +342,16 @@ if ENABLE_COMMANDS
# Binaries shipping with liblxc # Binaries shipping with liblxc
init_lxc_SOURCES = cmd/lxc_init.c \ init_lxc_SOURCES = cmd/lxc_init.c \
initutils.c initutils.h \ initutils.c initutils.h \
raw_syscalls.c raw_syscalls.h \
string_utils.c string_utils.h string_utils.c string_utils.h
lxc_monitord_SOURCES = cmd/lxc_monitord.c lxc_monitord_SOURCES = cmd/lxc_monitord.c \
raw_syscalls.c raw_syscalls.h
lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
../include/netns_ifaddrs.c ../include/netns_ifaddrs.h \ ../include/netns_ifaddrs.c ../include/netns_ifaddrs.h \
log.c log.h \ log.c log.h \
namespace.c namespace.h \ namespace.c namespace.h \
network.c network.h \ network.c network.h \
raw_syscalls.c raw_syscalls.h \
parse.c parse.h parse.c parse.h
lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c \ lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c \
conf.c conf.h \ conf.c conf.h \
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "raw_syscalls.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#include "error.h" #include "error.h"
#include "initutils.h" #include "initutils.h"
#include "log.h" #include "log.h"
#include "namespace.h"
#include "parse.h" #include "parse.h"
#include "raw_syscalls.h"
#include "string_utils.h" #include "string_utils.h"
/* option keys for long only options */ /* option keys for long only options */
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "log.h" #include "log.h"
#include "mainloop.h" #include "mainloop.h"
#include "monitor.h" #include "monitor.h"
#include "raw_syscalls.h"
#include "utils.h" #include "utils.h"
#define CLIENTFDS_CHUNK 64 #define CLIENTFDS_CHUNK 64
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "log.h" #include "log.h"
#include "lsm.h" #include "lsm.h"
#include "parse.h" #include "parse.h"
#include "raw_syscalls.h"
#include "utils.h" #include "utils.h"
lxc_log_define(apparmor, lsm); lxc_log_define(apparmor, lsm);
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include "namespace.h" #include "namespace.h"
#include "network.h" #include "network.h"
#include "parse.h" #include "parse.h"
#include "raw_syscalls.h"
#include "start.h" #include "start.h"
#include "state.h" #include "state.h"
#include "storage.h" #include "storage.h"
......
...@@ -140,13 +140,4 @@ extern int lxc_namespace_2_ns_idx(const char *namespace); ...@@ -140,13 +140,4 @@ extern int lxc_namespace_2_ns_idx(const char *namespace);
extern int lxc_namespace_2_std_identifiers(char *namespaces); extern int lxc_namespace_2_std_identifiers(char *namespaces);
extern int lxc_fill_namespace_flags(char *flaglist, int *flags); extern int lxc_fill_namespace_flags(char *flaglist, int *flags);
/**
* Because of older glibc's pid cache (up to 2.25) whenever clone() is called
* the child must must retrieve it's own pid via lxc_raw_getpid().
*/
static inline pid_t lxc_raw_getpid(void)
{
return (pid_t) syscall(SYS_getpid);
}
#endif #endif
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "macro.h" #include "macro.h"
#include "network.h" #include "network.h"
#include "nl.h" #include "nl.h"
#include "raw_syscalls.h"
#include "utils.h" #include "utils.h"
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <unistd.h>
/* /*
* lxc_raw_clone() - create a new process * lxc_raw_clone() - create a new process
...@@ -73,4 +74,13 @@ extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags ...@@ -73,4 +74,13 @@ extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags
extern int lxc_raw_execveat(int dirfd, const char *pathname, char *const argv[], extern int lxc_raw_execveat(int dirfd, const char *pathname, char *const argv[],
char *const envp[], int flags); char *const envp[], int flags);
/*
* Because of older glibc's pid cache (up to 2.25) whenever clone() is called
* the child must must retrieve it's own pid via lxc_raw_getpid().
*/
static inline pid_t lxc_raw_getpid(void)
{
return (pid_t)syscall(SYS_getpid);
}
#endif /* __LXC_RAW_SYSCALL_H */ #endif /* __LXC_RAW_SYSCALL_H */
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "file_utils.h" #include "file_utils.h"
#include "initutils.h" #include "initutils.h"
#include "macro.h" #include "macro.h"
#include "raw_syscalls.h"
#include "string_utils.h" #include "string_utils.h"
#ifdef HAVE_LINUX_MEMFD_H #ifdef HAVE_LINUX_MEMFD_H
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment