Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
b3243e6f
Commit
b3243e6f
authored
Jan 23, 2009
by
Adrian Robert
Browse files
* emacs.c (main): Do fork+exec under --daemon in Cocoa.
parent
e7534fc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
src/ChangeLog
src/ChangeLog
+4
-0
src/emacs.c
src/emacs.c
+51
-0
No files found.
src/ChangeLog
View file @
b3243e6f
2009-01-23 Adrian Robert <Adrian.B.Robert@gmail.com>
* emacs.c (main): Do fork+exec under --daemon in Cocoa.
2009-01-23 Giorgos Keramidas <keramida@freebsd.org> (tiny change)
* alloc.c (mark_stack): Use "flushw" instead of "ta 3" assembly
...
...
src/emacs.c
View file @
b3243e6f
...
...
@@ -797,6 +797,9 @@ main (int argc, char **argv)
int
no_loadup
=
0
;
char
*
junk
=
0
;
char
*
dname_arg
=
0
;
#ifdef NS_IMPL_COCOA
char
dname_arg2
[
80
];
#endif
#if GC_MARK_STACK
extern
Lisp_Object
*
stack_base
;
...
...
@@ -1108,7 +1111,19 @@ main (int argc, char **argv)
exit
(
1
);
}
#ifndef NS_IMPL_COCOA
f
=
fork
();
#else
/* Under Cocoa we must do fork+exec:
(http://developer.apple.com/ReleaseNotes/CoreFoundation/CoreFoundation.html)
We mark being in the exec'd process by a daemon name argument of
form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors,
NAME is the original daemon name, if any. */
if
(
!
dname_arg
||
!
strchr
(
dname_arg
,
'\n'
))
f
=
fork
();
/* in orig */
else
f
=
0
;
/* in exec'd */
#endif
if
(
f
>
0
)
{
int
retval
;
...
...
@@ -1144,6 +1159,42 @@ main (int argc, char **argv)
exit
(
1
);
}
#ifdef NS_IMPL_COCOA
{
/* in orig process, forked as child, OR in exec'd */
if
(
!
dname_arg
||
!
strchr
(
dname_arg
,
'\n'
))
{
/* in orig, child: now exec w/special daemon name */
char
fdStr
[
80
];
if
(
dname_arg
&&
strlen
(
dname_arg
)
>
70
)
{
fprintf
(
stderr
,
"daemon: child name too long
\n
"
);
exit
(
1
);
}
sprintf
(
fdStr
,
"--daemon=
\n
%d,%d
\n
%s"
,
daemon_pipe
[
0
],
daemon_pipe
[
1
],
dname_arg
?
dname_arg
:
""
);
argv
[
skip_args
]
=
fdStr
;
execv
(
argv
[
0
],
argv
);
fprintf
(
stderr
,
"emacs daemon: exec failed: %d
\t
%d
\n
"
,
errno
);
exit
(
1
);
}
/* in exec'd: parse special dname into pipe and name info */
if
(
!
dname_arg
||
!
strchr
(
dname_arg
,
'\n'
)
||
strlen
(
dname_arg
)
<
1
||
strlen
(
dname_arg
)
>
70
)
{
fprintf
(
stderr
,
"emacs daemon: daemon name absent or too long
\n
"
);
exit
(
1
);
}
dname_arg2
[
0
]
=
'\0'
;
sscanf
(
dname_arg
,
"
\n
%d,%d
\n
%s"
,
&
(
daemon_pipe
[
0
]),
&
(
daemon_pipe
[
1
]),
dname_arg2
);
dname_arg
=
strlen
(
dname_arg2
)
?
dname_arg2
:
NULL
;
}
#endif
if
(
dname_arg
)
daemon_name
=
xstrdup
(
dname_arg
);
/* Close unused reading end of the pipe. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment