Make sure uninstall.sh is executed on remove

This commit is contained in:
topjohnwu
2019-11-01 03:07:12 -04:00
parent 493068c073
commit 8277896ca1
5 changed files with 46 additions and 33 deletions

View File

@@ -198,3 +198,17 @@ uint32_t binary_gcd(uint32_t u, uint32_t v) {
} while (v != 0);
return u << shift;
}
int switch_mnt_ns(int pid) {
char mnt[32];
snprintf(mnt, sizeof(mnt), "/proc/%d/ns/mnt", pid);
if (access(mnt, R_OK) == -1) return 1; // Maybe process died..
int fd, ret;
fd = xopen(mnt, O_RDONLY);
if (fd < 0) return 1;
// Switch to its namespace
ret = xsetns(fd, 0);
close(fd);
return ret;
}

View File

@@ -15,6 +15,7 @@ void init_argv0(int argc, char **argv);
void set_nice_name(const char *name);
int parse_int(const char *s);
uint32_t binary_gcd(uint32_t u, uint32_t v);
int switch_mnt_ns(int pid);
#ifdef __cplusplus
}
@@ -96,4 +97,4 @@ int exec_command_sync(Args &&...args) {
bool ends_with(const std::string_view &s1, const std::string_view &s2);
#endif
#endif