Skip to content

Commit

Permalink
server: free spawn attributes and file actions
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 1, 2022
1 parent 5106630 commit a7cb5a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/remote_server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ int internal_spawn(char *const *argv, char *const *envp, pid_t *pid)
slave_fd = open(slave_pty_name, O_RDWR);
CHECK(-1 != slave_fd);

// call setsid() on child so Ctrl-C can be interpret
// call setsid() on child so Ctrl-C and all other control characters are set in a different terminal
// and process group
posix_spawnattr_t attr;
CHECK(0 == posix_spawnattr_init(&attr));
CHECK(0 == posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSID));
Expand All @@ -156,9 +157,11 @@ int internal_spawn(char *const *argv, char *const *envp, pid_t *pid)
CHECK(0 == posix_spawn_file_actions_addclose(&actions, slave_fd));
CHECK(0 == posix_spawn_file_actions_addclose(&actions, master_fd));


CHECK(0 == posix_spawnp(pid, argv[0], &actions, &attr, argv, envp));

posix_spawnattr_destroy(&attr);
posix_spawn_file_actions_destroy(&actions);

close(slave_fd);
slave_fd = -1;

Expand Down

0 comments on commit a7cb5a6

Please sign in to comment.