/*
process.c -- process management functions
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-2009 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2011 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
extern char **g_argv;
extern bool use_logfile;
+#ifndef HAVE_MINGW
sigset_t emptysigset;
+#endif
static void memory_full(int size) {
logger(LOG_ERR, "Memory exhausted (couldn't allocate %d bytes), exitting.", size);
command, NULL, NULL, NULL, NULL, NULL);
if(!service) {
- logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(GetLastError()));
- return false;
+ DWORD lasterror = GetLastError();
+ logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror));
+ if(lasterror != ERROR_SERVICE_EXISTS)
+ return false;
}
- ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description);
-
- logger(LOG_INFO, "%s service installed", identname);
+ if(service) {
+ ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description);
+ logger(LOG_INFO, "%s service installed", identname);
+ } else {
+ service = OpenService(manager, identname, SERVICE_ALL_ACCESS);
+ }
if(!StartService(service, 0, NULL))
logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError()));
bool execute_script(const char *name, char **envp) {
#ifdef HAVE_SYSTEM
int status, len;
- char *scriptname, *p;
+ char *scriptname;
int i;
#ifndef HAVE_MINGW
for(i = 0; envp[i]; i++) {
char *e = strchr(envp[i], '=');
if(e) {
- p = alloca(e - envp[i] + 1);
+ char p[e - envp[i] + 1];
strncpy(p, envp[i], e - envp[i]);
p[e - envp[i]] = '\0';
putenv(p);
{SIGILL, fatal_signal_handler},
{SIGPIPE, ignore_signal_handler},
{SIGCHLD, ignore_signal_handler},
+ {SIGABRT, SIG_DFL},
{0, NULL}
};
#endif