2003-06-18 09:56:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file kill.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
2003-07-28 22:37:28 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-01-17 21:01:30 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2004-11-07 13:22:51 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2000-01-17 21:01:30 +00:00
|
|
|
|
|
2005-04-26 10:30:24 +00:00
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
|
#endif
|
2002-06-10 17:31:57 +00:00
|
|
|
|
#include <csignal>
|
2002-06-10 07:57:39 +00:00
|
|
|
|
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "os.h"
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
2006-09-07 15:23:16 +00:00
|
|
|
|
#include <cerrno>
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#endif //_WIN32
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
int support::kill(int pid, int sig)
|
2000-01-17 21:01:30 +00:00
|
|
|
|
{
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#ifdef _WIN32
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (pid == (int)GetCurrentProcessId())
|
|
|
|
|
return -raise(sig);
|
|
|
|
|
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
|
|
|
|
|
if (!hProcess) {
|
|
|
|
|
lyxerr << "kill OpenProcess failed!" << std::endl;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (!TerminateProcess(hProcess, sig)) {
|
2006-10-21 07:26:07 +00:00
|
|
|
|
lyxerr << "kill process failed!" << std::endl;
|
2005-01-31 15:26:40 +00:00
|
|
|
|
CloseHandle(hProcess);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
return -1;
|
2005-01-31 15:26:40 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
CloseHandle(hProcess);
|
2005-01-31 15:26:40 +00:00
|
|
|
|
return 0;
|
|
|
|
|
#else
|
2000-01-17 21:01:30 +00:00
|
|
|
|
return ::kill(pid, sig);
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#endif
|
2000-01-17 21:01:30 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|