proper forking of spawned processes

This commit is contained in:
nova
2026-05-21 01:11:56 +02:00
parent 41af25e0b1
commit 9f7ed73885
2 changed files with 35 additions and 13 deletions

View File

@@ -226,8 +226,18 @@ void move_right(){
if (extension <= mid_dir.current_file->file_name + strlen(mid_dir.current_file->file_name)) {
for (i = 0; i < file_extension_default_count; i++) {
if (strcmp(extension, file_extension_default_cmd[i].file_extension) == 0) {
cmd = parse_cmd(file_extension_default_cmd[i].command, mid_dir.current_file);
if (system(cmd)) {
if (file_extension_default_cmd[i].command[0] == SETTINGS_COMMAND_FORK) {
cmd = parse_cmd(file_extension_default_cmd[i].command + 1, mid_dir.current_file);
pid_t pid = fork();
if (pid == 0 && setsid()) {
system(cmd);
status = STATUS_QUIT_PROGRAM;
exit(1);
}
} else {
cmd = parse_cmd(file_extension_default_cmd[i].command, mid_dir.current_file);
if (system(cmd)) {
}
}
status |= STATUS_MOVE_RIGHT_MATCH;
update();
@@ -238,9 +248,20 @@ void move_right(){
if (!(status & STATUS_MOVE_RIGHT_MATCH)) {
for (i = 0; i < mimetype_default_count; i++) {
if (strstr(mime, mimetype_default_cmd[i].mimetype)) {
cmd = parse_cmd(mimetype_default_cmd[i].command, mid_dir.current_file);
if (system(cmd)) {
if (mimetype_default_cmd[i].command[0] == SETTINGS_COMMAND_FORK) {
cmd = parse_cmd(mimetype_default_cmd[i].command + 1, mid_dir.current_file);
pid_t pid = fork();
if (pid == 0 && setsid()) {
system(cmd);
status = STATUS_QUIT_PROGRAM;
exit(1);
}
} else {
cmd = parse_cmd(mimetype_default_cmd[i].command, mid_dir.current_file);
if (system(cmd)) {
}
}
status |= STATUS_MOVE_RIGHT_MATCH;
update();
break;
}