2 * minit version 0.9.1 by Felix von Leitner
3 * ported to busybox by Glenn McGrath <bug1@optushome.com.au>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <sys/fcntl.h>
26 /* purpose: argv[1] is the full path to a PID file,
27 * argv+2 is the daemon to run.
28 * the daemon is expected to fork in the background and write its PID in
32 extern int pidfilehack_main(int argc, char **argv)
40 if (unlink(argv[2]) && (errno != ENOENT)) {
41 bb_perror_msg("could not remove pid file");
45 bb_perror_msg("could not fork");
48 execv(argv[3], argv + 3);
49 bb_perror_msg("execvp failed");
53 int fd = open(argv[2], O_RDONLY);
56 static char buf[100] = "-P";
57 int len = read(fd, buf + 2, 100);
61 char *_argv[] = { "msvc", 0, 0, 0 };
62 if (buf[len + 1] == '\n') {
69 execvp(_argv[0], _argv);
70 bb_perror_msg("execvp failed");
75 } while (++count < 30);