XQuartz: Don't fork to exec app_to_run.
Plus other housecleaning... (cherry picked from commit ae302db472f127be082d05b418ede332fae8ccc5)
This commit is contained in:
parent
2d15d439f8
commit
1f74bef1ad
|
@ -153,7 +153,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
|
||||||
|
|
||||||
tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
|
tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
|
||||||
|
|
||||||
[dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem]
|
[dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION]
|
||||||
forKey:@"ApplicationVersion"];
|
forKey:@"ApplicationVersion"];
|
||||||
|
|
||||||
[self orderFrontStandardAboutPanelWithOptions: dict];
|
[self orderFrontStandardAboutPanelWithOptions: dict];
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
|
|
||||||
3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
|
3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
|
||||||
527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
|
527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
|
||||||
527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
|
527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
|
||||||
|
@ -22,7 +21,6 @@
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
|
1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
|
||||||
3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
|
|
||||||
3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
|
3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
|
||||||
50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
|
50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
|
||||||
50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
|
50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
|
||||||
|
@ -69,7 +67,6 @@
|
||||||
20286C2AFDCF999611CA2CEA /* Sources */ = {
|
20286C2AFDCF999611CA2CEA /* Sources */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
|
|
||||||
3F5E1BDF0D04BF110020CA24 /* server-main.c */,
|
3F5E1BDF0D04BF110020CA24 /* server-main.c */,
|
||||||
50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
|
50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
|
||||||
);
|
);
|
||||||
|
@ -176,7 +173,6 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
|
527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
|
||||||
3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
|
|
||||||
3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
|
3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|
|
@ -32,18 +32,23 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
int launcher_main(int argc, char **argv);
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
|
#define DEFAULT_APP "/usr/X11/bin/xterm"
|
||||||
|
|
||||||
|
static int launcher_main(int argc, char **argv);
|
||||||
int server_main(int argc, char **argv);
|
int server_main(int argc, char **argv);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Display *display;
|
Display *display;
|
||||||
|
|
||||||
//size_t i;
|
size_t i;
|
||||||
//fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
|
fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
|
||||||
//for(i=0; i < argc; i++) {
|
for(i=0; i < argc; i++) {
|
||||||
// fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
|
fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
|
||||||
//}
|
}
|
||||||
|
|
||||||
/* If we have a process serial number and it's our only arg, act as if
|
/* If we have a process serial number and it's our only arg, act as if
|
||||||
* the user double clicked the app bundle: launch app_to_run if possible
|
* the user double clicked the app bundle: launch app_to_run if possible
|
||||||
|
@ -52,7 +57,7 @@ int main(int argc, char **argv) {
|
||||||
/* Now, try to open a display, if so, run the launcher */
|
/* Now, try to open a display, if so, run the launcher */
|
||||||
display = XOpenDisplay(NULL);
|
display = XOpenDisplay(NULL);
|
||||||
if(display) {
|
if(display) {
|
||||||
fprintf(stderr, "X11.app: main(): closing the display and sleeping");
|
fprintf(stderr, "X11.app: closing the display and sleeping for 2s to allow the X server to start up.\n");
|
||||||
/* Could open the display, start the launcher */
|
/* Could open the display, start the launcher */
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
|
|
||||||
|
@ -60,13 +65,49 @@ int main(int argc, char **argv) {
|
||||||
* TODO: *Really* fix this race condition
|
* TODO: *Really* fix this race condition
|
||||||
*/
|
*/
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
//fprintf(stderr, "X11.app: main(): running launcher_main()");
|
|
||||||
return launcher_main(argc, argv);
|
return launcher_main(argc, argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the server */
|
/* Start the server */
|
||||||
//fprintf(stderr, "X11.app: main(): running server_main()");
|
fprintf(stderr, "X11.app: main(): running server_main()");
|
||||||
return server_main(argc, argv);
|
return server_main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int launcher_main (int argc, char **argv) {
|
||||||
|
char *command = DEFAULT_APP;
|
||||||
|
const char *newargv[7];
|
||||||
|
int child;
|
||||||
|
const char **s;
|
||||||
|
|
||||||
|
CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"), kCFPreferencesCurrentApplication);
|
||||||
|
|
||||||
|
if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
|
||||||
|
CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), kCFPreferencesCurrentApplication);
|
||||||
|
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
||||||
|
} else {
|
||||||
|
int len = CFStringGetLength((CFStringRef)PlistRef)+1;
|
||||||
|
command = (char *)malloc(len);
|
||||||
|
CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII);
|
||||||
|
fprintf(stderr, "command=%s\n", command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PlistRef) CFRelease(PlistRef);
|
||||||
|
|
||||||
|
newargv[0] = "/usr/bin/login";
|
||||||
|
newargv[1] = "-fp";
|
||||||
|
newargv[2] = getlogin();
|
||||||
|
newargv[3] = "/bin/sh";
|
||||||
|
newargv[4] = "-c";
|
||||||
|
newargv[5] = command;
|
||||||
|
newargv[6] = NULL;
|
||||||
|
|
||||||
|
fprintf(stderr, "X11.app: Launching X11 Application:\n");
|
||||||
|
for(s=newargv; *s; s++) {
|
||||||
|
fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
|
||||||
|
}
|
||||||
|
|
||||||
|
execvp (newargv[0], (const char **) newargv);
|
||||||
|
perror ("X11.app: Couldn't exec.");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
|
@ -150,8 +150,9 @@ void
|
||||||
DarwinPrintBanner(void)
|
DarwinPrintBanner(void)
|
||||||
{
|
{
|
||||||
// this should change depending on which specific server we are building
|
// this should change depending on which specific server we are building
|
||||||
ErrorF("X11.app starting:\n");
|
ErrorF("XQuartz starting:\n");
|
||||||
ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
|
ErrorF("X.org Release 7.2\n"); // This is here to help fink until they fix their packages.
|
||||||
|
ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue