util: Make ns_enter() a void function and report setns() errors
ns_enter() returns an integer... but it's always zero. If we actually fail the function doesn't return. Therefore it makes more sense for this to be a function returning void, and we can remove the cases where we pointlessly checked its return value. In addition ns_enter() is usually called from an ephemeral thread created by NS_CALL(). That means that the exit(EXIT_FAILURE) there usually won't be reported (since NS_CALL() doesn't wait() for the thread). So, use die() instead to print out some information in the unlikely event that our setns() here does fail. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:

committed by
Stefano Brivio

parent
b15ce5b6ce
commit
6920adda0d
2
util.h
2
util.h
@@ -216,7 +216,7 @@ int bitmap_isset(const uint8_t *map, int bit);
|
||||
char *line_read(char *buf, size_t len, int fd);
|
||||
void procfs_scan_listen(struct ctx *c, uint8_t proto, int ip_version, int ns,
|
||||
uint8_t *map, uint8_t *exclude);
|
||||
int ns_enter(const struct ctx *c);
|
||||
void ns_enter(const struct ctx *c);
|
||||
bool ns_is_init(void);
|
||||
void write_pidfile(int fd, pid_t pid);
|
||||
int __daemon(int pidfile_fd, int devnull_fd);
|
||||
|
Reference in New Issue
Block a user