forked from emacs-mirror/emacs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emacswrapper.c
56 lines (46 loc) · 1.03 KB
/
emacswrapper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* emacswrapper.c -*- C -*- */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <err.h>
#include <sysexits.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "dumpemacs.h"
/* only one function so far: */
int main(int argc, char *argv[])
{
int ret;
#if defined(DEBUG) || defined(lint)
printf("Program is running from path '%s' with '%i' argument(s).\n",
argv[0], argc);
#else
(void)argc;
#endif /* DEBUG || lint */
if (!is_emacs_valid(0)) {
const char *newargs[2];
newargs[0] = kDumpEmacsPath;
if (geteuid() != 0) {
newargs[1] = "-n";
newargs[2] = NULL;
} else {
newargs[1] = NULL;
}
ret = runit(newargs, 0);
if (ret) {
errx(1, "Failed to dump emacs");
}
}
#ifdef DEBUG
printf("Done running dumpemacs.\n");
#endif /* DEBUG */
ret = execv(kEmacsArchPath, argv);
if (ret) {
err(EX_OSERR, "execv(%s) failed", kEmacsArchPath);
}
/* we should never get here: */
return EX_OSERR;
}
/* EOF */