Mercurial > vim
comparison src/os_unix.c @ 15123:7d2ed364a8a0 v8.1.0572
patch 8.1.0572: stopping a job does not work properly on OpenBSD
commit https://github.com/vim/vim/commit/76ab4fd61901090e6af3451ca6c5ca0fc370571f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 8 14:39:05 2018 +0100
patch 8.1.0572: stopping a job does not work properly on OpenBSD
Problem: Stopping a job does not work properly on OpenBSD.
Solution: Do not use getpgid() to check the process group of the job
processs ID, always pass the negative process ID to kill().
(George Koehler, closes #3656)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 08 Dec 2018 14:45:05 +0100 |
parents | 588a5fafbb61 |
children | de63593896b3 |
comparison
equal
deleted
inserted
replaced
15122:91fafb38608c | 15123:7d2ed364a8a0 |
---|---|
5818 */ | 5818 */ |
5819 int | 5819 int |
5820 mch_signal_job(job_T *job, char_u *how) | 5820 mch_signal_job(job_T *job, char_u *how) |
5821 { | 5821 { |
5822 int sig = -1; | 5822 int sig = -1; |
5823 pid_t job_pid; | |
5824 | 5823 |
5825 if (*how == NUL || STRCMP(how, "term") == 0) | 5824 if (*how == NUL || STRCMP(how, "term") == 0) |
5826 sig = SIGTERM; | 5825 sig = SIGTERM; |
5827 else if (STRCMP(how, "hup") == 0) | 5826 else if (STRCMP(how, "hup") == 0) |
5828 sig = SIGHUP; | 5827 sig = SIGHUP; |
5839 else if (isdigit(*how)) | 5838 else if (isdigit(*how)) |
5840 sig = atoi((char *)how); | 5839 sig = atoi((char *)how); |
5841 else | 5840 else |
5842 return FAIL; | 5841 return FAIL; |
5843 | 5842 |
5844 /* TODO: have an option to only kill the process, not the group? */ | 5843 // Never kill ourselves! |
5845 job_pid = job->jv_pid; | 5844 if (job->jv_pid != 0) |
5846 #ifdef HAVE_GETPGID | 5845 { |
5847 if (job_pid == getpgid(job_pid)) | 5846 // TODO: have an option to only kill the process, not the group? |
5848 job_pid = -job_pid; | 5847 kill(-job->jv_pid, sig); |
5849 #endif | 5848 kill(job->jv_pid, sig); |
5850 | 5849 } |
5851 /* Never kill ourselves! */ | |
5852 if (job_pid != 0) | |
5853 kill(job_pid, sig); | |
5854 | 5850 |
5855 return OK; | 5851 return OK; |
5856 } | 5852 } |
5857 | 5853 |
5858 /* | 5854 /* |