- if(chdir(confbase) < 0)
- /* This cannot fail since we already read config files from this
- directory. - Guus */
- /* Yes this can fail, somebody could have removed this directory
- when we didn't pay attention. - Ivo */
- {
- if(chdir("/") < 0)
- /* Now if THIS fails, something wicked is going on. - Ivo */
- syslog(LOG_ERR, _("Couldn't chdir to `/': %m"));
-
- /* Continue anyway. */
- }
-
- asprintf(&scriptname, "%s/%s", confbase, name);
-
- /* Close all file descriptors */
- closelog();
- fcloseall();
-
- /* Open standard input */
- if((fd = open("/dev/null", O_RDONLY)) < 0)
- {
- syslog(LOG_ERR, _("Opening `/dev/null' failed: %m"));
- error = 1;
- }
- if(dup2(fd, 0) != 0)
- {
- syslog(LOG_ERR, _("Couldn't assign /dev/null to standard input: %m"));
- error = 1;
- }
-
- if(!error)
- {
- close(1); /* fd #1 should be the first available filedescriptor now. */
- /* Standard output directly goes to syslog */
- openlog(name, LOG_CONS | LOG_PID, LOG_DAEMON);
- /* Standard error as well */
- if(dup2(1, 2) < 0)
- {
- syslog(LOG_ERR, _("System call `%s' failed: %m"),
- "dup2");
- error = 1;
+ if(!StartService(service, 0, NULL)) {
+ logger(DEBUG_ALWAYS, LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError()));
+ } else {
+ logger(DEBUG_ALWAYS, LOG_INFO, "%s service started", identname);