2 * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * Except as contained in this notice, the name of Conectiva Linux shall
23 * not be used in advertising or otherwise to promote the sale, use or other
24 * dealings in this Software without prior written authorization from
27 * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
32 #include <sys/types.h>
50 if (getenv("DISPLAY") != NULL
)
51 /* already running Xserver */
54 if (XF86Config_path
== NULL
) {
55 char *home
, filename
[PATH_MAX
];
56 char commandline
[PATH_MAX
* 4];
60 * The name of the 4.0 binary is XFree86. X might also
61 * be the name of the 3.3 binary. Therefore don't change
65 c_pos
= XmuSnprintf(commandline
, sizeof(commandline
),
66 "%s/"__XSERVERNAME__
" :8 -configure ",XFree86_path
);
68 c_pos
= XmuSnprintf(commandline
, sizeof(commandline
),
69 "%s/bin/"__XSERVERNAME__
" :8 -configure ", XFree86Dir
);
70 if (XF86Module_path
&& ((len
= sizeof(commandline
) - c_pos
) > 0))
71 c_pos
+= XmuSnprintf(commandline
+ c_pos
,len
,
72 " -modulepath %s",XF86Module_path
);
73 if (XF86Font_path
&& ((len
= sizeof(commandline
) - c_pos
) > 0))
74 c_pos
+= XmuSnprintf(commandline
+ c_pos
,len
,
75 " -fontpath %s",XF86Font_path
);
76 if (XF86RGB_path
&& ((len
= sizeof(commandline
) - c_pos
) > 0))
77 c_pos
+= XmuSnprintf(commandline
+ c_pos
,len
,
78 " -rgbpath %s",XF86RGB_path
);
80 if (system(commandline
) != 0) {
81 fprintf(stderr
, "Failed to run \"X -configure\".\n");
85 if ((home
= getenv("HOME")) == NULL
)
89 XmuSnprintf(filename
, sizeof(filename
), "%s/"__XCONFIGFILE__
".new", home
);
91 XmuSnprintf(filename
, sizeof(filename
), "//%d%s/"__XCONFIGFILE__
".new",
95 /* this memory is never released, even if the value of XF86Config_path is
98 XF86Config_path
= XtNewString(filename
);
101 putenv("DISPLAY=:8");
103 switch (xpid
= fork()) {
106 /* Don't change to X! see above */
108 XmuSnprintf(path
, sizeof(path
), "%s/"__XSERVERNAME__
, XFree86_path
);
110 XmuSnprintf(path
, sizeof(path
), "%s/bin/"__XSERVERNAME__
, XFree86Dir
);
111 execl(path
, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail",
112 "-xf86config", XF86Config_path
, (void *)NULL
);
116 fprintf(stderr
, "Cannot fork.\n");
123 while (timeout
> 0) {
127 if (waitpid(xpid
, &status
, WNOHANG
| WUNTRACED
) == xpid
)
130 DPY
= XOpenDisplay(NULL
);
137 fprintf(stderr
, "Cannot connect to X server.\n");