Mercurial > vim
comparison src/os_unix.c @ 13357:179586a64f53 v8.0.1552
patch 8.0.1552: may leak file descriptors when executing job
commit https://github.com/vim/vim/commit/8195247054a659fe5cbc238197634d5e13e8e8e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 27 19:10:00 2018 +0100
patch 8.0.1552: may leak file descriptors when executing job
Problem: May leak file descriptors when executing job.
Solution: Close more file descriptors. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2531)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 27 Feb 2018 19:15:05 +0100 |
parents | 0bc67f4e2947 |
children | 69517d67421f |
comparison
equal
deleted
inserted
replaced
13356:2f4f6fc72c1c | 13357:179586a64f53 |
---|---|
4598 } | 4598 } |
4599 else if (pid == 0) /* child */ | 4599 else if (pid == 0) /* child */ |
4600 { | 4600 { |
4601 reset_signals(); /* handle signals normally */ | 4601 reset_signals(); /* handle signals normally */ |
4602 UNBLOCK_SIGNALS(&curset); | 4602 UNBLOCK_SIGNALS(&curset); |
4603 | |
4604 # ifdef FEAT_JOB_CHANNEL | |
4605 if (ch_log_active()) | |
4606 /* close the log file in the child */ | |
4607 ch_logfile((char_u *)"", (char_u *)""); | |
4608 # endif | |
4603 | 4609 |
4604 if (!show_shell_mess || (options & SHELL_EXPAND)) | 4610 if (!show_shell_mess || (options & SHELL_EXPAND)) |
4605 { | 4611 { |
4606 int fd; | 4612 int fd; |
4607 | 4613 |
5452 | 5458 |
5453 /* child */ | 5459 /* child */ |
5454 reset_signals(); /* handle signals normally */ | 5460 reset_signals(); /* handle signals normally */ |
5455 UNBLOCK_SIGNALS(&curset); | 5461 UNBLOCK_SIGNALS(&curset); |
5456 | 5462 |
5463 # ifdef FEAT_JOB_CHANNEL | |
5464 if (ch_log_active()) | |
5465 /* close the log file in the child */ | |
5466 ch_logfile((char_u *)"", (char_u *)""); | |
5467 # endif | |
5468 | |
5457 # ifdef HAVE_SETSID | 5469 # ifdef HAVE_SETSID |
5458 /* Create our own process group, so that the child and all its | 5470 /* Create our own process group, so that the child and all its |
5459 * children can be kill()ed. Don't do this when using pipes, | 5471 * children can be kill()ed. Don't do this when using pipes, |
5460 * because stdin is not a tty, we would lose /dev/tty. */ | 5472 * because stdin is not a tty, we would lose /dev/tty. */ |
5461 (void)setsid(); | 5473 (void)setsid(); |
5585 job->jv_channel = channel; /* ch_refcount was set above */ | 5597 job->jv_channel = channel; /* ch_refcount was set above */ |
5586 | 5598 |
5587 if (pty_master_fd >= 0) | 5599 if (pty_master_fd >= 0) |
5588 close(pty_slave_fd); /* not used in the parent */ | 5600 close(pty_slave_fd); /* not used in the parent */ |
5589 /* close child stdin, stdout and stderr */ | 5601 /* close child stdin, stdout and stderr */ |
5590 if (!use_file_for_in && fd_in[0] >= 0) | 5602 if (fd_in[0] >= 0) |
5591 close(fd_in[0]); | 5603 close(fd_in[0]); |
5592 if (!use_file_for_out && fd_out[1] >= 0) | 5604 if (fd_out[1] >= 0) |
5593 close(fd_out[1]); | 5605 close(fd_out[1]); |
5594 if (!use_out_for_err && !use_file_for_err && fd_err[1] >= 0) | 5606 if (fd_err[1] >= 0) |
5595 close(fd_err[1]); | 5607 close(fd_err[1]); |
5596 if (channel != NULL) | 5608 if (channel != NULL) |
5597 { | 5609 { |
5598 channel_set_pipes(channel, | 5610 channel_set_pipes(channel, |
5599 use_file_for_in || use_null_for_in | 5611 use_file_for_in || use_null_for_in |