mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 14:32:04 +00:00
aabd481ab6
include <config.h> in .C files, not .h ones; licence blurb. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9876 a592a061-630c-0410-9148-cb99ea01b6c8
55 lines
990 B
C
55 lines
990 B
C
/**
|
|
* \file kill.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars Gullik Bjønnes
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "support/lyxlib.h"
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
# include <sys/types.h>
|
|
#endif
|
|
#include <csignal>
|
|
|
|
#ifdef _WIN32
|
|
#include "debug.h"
|
|
#include "os.h"
|
|
|
|
#include <windows.h>
|
|
#include <errno.h>
|
|
|
|
using std::endl;
|
|
#endif //_WIN32
|
|
|
|
int lyx::support::kill(int pid, int sig)
|
|
{
|
|
#ifdef _WIN32
|
|
if (pid == (int)GetCurrentProcessId()) {
|
|
return -(raise(sig));
|
|
} else {
|
|
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
|
|
if (!hProcess) {
|
|
lyxerr << "kill OpenProcess failed!" << endl;
|
|
return -1;
|
|
} else {
|
|
if (!TerminateProcess(hProcess, sig)){
|
|
lyxerr << "kill process failed!" << endl;
|
|
CloseHandle(hProcess);
|
|
return -1;
|
|
}
|
|
CloseHandle(hProcess);
|
|
}
|
|
}
|
|
return 0;
|
|
|
|
#else
|
|
return ::kill(pid, sig);
|
|
#endif
|
|
}
|