mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 23:45:58 +01:00
Fix exec_before/after leaving a zombie process behind
This commit is contained in:
parent
5f5a29ccfd
commit
9ef1d6aa2b
1 changed files with 23 additions and 13 deletions
|
@ -19,20 +19,30 @@ static const char object_path[] = "/org/freedesktop/portal/desktop";
|
||||||
static const char interface_name[] = "org.freedesktop.impl.portal.ScreenCast";
|
static const char interface_name[] = "org.freedesktop.impl.portal.ScreenCast";
|
||||||
|
|
||||||
void exec_with_shell(char *command) {
|
void exec_with_shell(char *command) {
|
||||||
pid_t pid = fork();
|
pid_t pid1 = fork();
|
||||||
if (pid < 0) {
|
if (pid1 < 0) {
|
||||||
perror("fork");
|
perror("fork");
|
||||||
} else if (pid == 0) {
|
return;
|
||||||
char *const argv[] = {
|
} else if (pid1 == 0) {
|
||||||
"sh",
|
pid_t pid2 = fork();
|
||||||
"-c",
|
if (pid2 < 0) {
|
||||||
command,
|
perror("fork");
|
||||||
NULL,
|
} else if (pid2 == 0) {
|
||||||
};
|
char *const argv[] = {
|
||||||
execvp("sh", argv);
|
"sh",
|
||||||
|
"-c",
|
||||||
perror("execvp");
|
command,
|
||||||
exit(127);
|
NULL,
|
||||||
|
};
|
||||||
|
execvp("sh", argv);
|
||||||
|
perror("execvp");
|
||||||
|
_exit(127);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
int stat;
|
||||||
|
if (waitpid(pid1, &stat, 0) < 0) {
|
||||||
|
perror("waitpid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue