From: Johannes Sixt Date: Sat, 03 Aug 2013 10:40:37 GMT Subject: Re: [PATCH v2] gc: reject if another gc is running, unless --force is given Message-ID: <51FCDE25.9080805@kdbg.org> In-Reply-To: <20130803100113.GA8239@lanh> Am 03.08.2013 12:01, schrieb Duy Nguyen: > On Sat, Aug 03, 2013 at 11:49:02AM +0200, Johannes Sixt wrote: >> Am 03.08.2013 08:21, schrieb Nguyễn Thái Ngọc Duy: >>> I changed mingw.h to add a stub uname() because I don't think MinGW >>> port has that function, but that's totally untested. >> >> Thanks, but we don't have kill(pid, 0), either :-( > > Yeah, I should have checked. Will this work? > > -- 8< -- > diff --git a/compat/mingw.c b/compat/mingw.c > index bb92c43..14d92df 100644 > --- a/compat/mingw.c > +++ b/compat/mingw.c > @@ -1086,6 +1086,12 @@ int mingw_kill(pid_t pid, int sig) > errno = err_win_to_posix(GetLastError()); > CloseHandle(h); > return -1; > + } else if (pid > 0 && sig == 0) { > + HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid); > + if (h) { > + CloseHandle(h); > + return 0; > + } > } > > errno = EINVAL; > -- 8< -- > Looks reasonable. PROCESS_QUERY_INFORMATION instead of PROCESS_TERMINATE should be sufficient, and errno = ESRCH; return -1; is missing. -- Hannes