Gentoo Archives: gentoo-commits

From: "Sebastien Fabbro (bicatali)" <bicatali@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-libs/xpa/files: xpa-2.1.8-ds9-5.4.patch xpa-2.1.8-makefile.patch
Date: Wed, 05 Nov 2008 21:45:15
Message-Id: E1KxqBb-0006ig-QI@stork.gentoo.org
1 bicatali 08/11/05 21:45:11
2
3 Added: xpa-2.1.8-ds9-5.4.patch xpa-2.1.8-makefile.patch
4 Log:
5 Initial import
6 (Portage version: 2.2_rc11/cvs/Linux 2.6.25-gentoo-r7 x86_64)
7
8 Revision Changes Path
9 1.1 x11-libs/xpa/files/xpa-2.1.8-ds9-5.4.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-libs/xpa/files/xpa-2.1.8-ds9-5.4.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-libs/xpa/files/xpa-2.1.8-ds9-5.4.patch?rev=1.1&content-type=text/plain
13
14 Index: xpa-2.1.8-ds9-5.4.patch
15 ===================================================================
16 --- xpa-2.1.8.orig/configure.ac 2007-04-04 15:09:51.000000000 +0100
17 +++ xpa-2.1.8/configure.ac 2007-12-18 20:09:26.000000000 +0000
18 @@ -41,7 +41,7 @@
19
20 AC_C_CONST
21
22 -AC_CHECK_FUNCS(strchr memcpy snprintf atexit)
23 +AC_CHECK_FUNCS(strchr memcpy snprintf atexit setenv posix_spawn)
24
25 AC_CHECK_FUNC(connect)
26 if test $ac_cv_func_connect = no; then
27 @@ -60,7 +60,7 @@
28 AC_MSG_CHECKING(for threaded xpans)
29 AC_ARG_ENABLE(threaded-xpans, [ --enable-threaded-xpans build threaded xpans],
30 [fun_ok=$enableval], [fun_ok=no])
31 -if test "$fun_ok" != "no"; then
32 +if test "$fun_ok" = "yes"; then
33 AC_MSG_RESULT($fun_ok)
34 AC_CHECK_LIB(pthread, pthread_create, have_pthread=yes)
35 if test x"${have_pthread}" = x"yes"; then
36 @@ -78,7 +78,7 @@
37 AC_MSG_CHECKING(for shared library build)
38 AC_ARG_ENABLE(shared, [ --enable-shared build shared libraries],
39 [fun_ok=$enableval], [fun_ok=no])
40 -if test "$fun_ok" != "no"; then
41 +if test "$fun_ok" = "yes"; then
42 fpic="yes"
43 DOSHARED=shlib
44 AC_SUBST(DOSHARED)
45 @@ -93,8 +93,16 @@
46 AC_SUBST(LLIB)
47 AC_MSG_RESULT($fun_ok)
48
49 +AC_MSG_CHECKING(for request to use posix_spawn)
50 +AC_ARG_ENABLE(posix_spawn, [ --enable-posix_spawn use posix_spawn() if available],
51 + [fun_ok=$enableval], [fun_ok=no])
52 +AC_MSG_RESULT($fun_ok)
53 +if test "$fun_ok" = "yes"; then
54 + AC_CHECK_FUNCS(posix_spawn)
55 +fi
56 +
57 AC_PATH_XTRA
58 -if test x"${have_x}" != "xno"; then
59 +if test x"${have_x}" = "xyes"; then
60 AC_DEFINE(HAVE_XT)
61 fi
62
63 --- xpa-2.1.8.orig/launch.c 2006-01-27 16:51:02.000000000 +0000
64 +++ xpa-2.1.8/launch.c 2007-12-18 20:09:26.000000000 +0000
65 @@ -1,35 +1,9 @@
66 /*
67 - * Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
68 + * Copyright (c) 1999-2007 Smithsonian Astrophysical Observatory
69 */
70
71 #include <launch.h>
72
73 -#define LAUNCHARGS 1024
74 -
75 -/* we one of these must be defined ... */
76 -#if !defined(USE_PIPE) && !defined(USE_WAITPID)
77 -#define USE_PIPE 1
78 -#endif
79 -/* ... but not both */
80 -#if defined(USE_PIPE) && defined(USE_WAITPID)
81 -#error "USE_PIPE and USE_WAITPID are mutually exclusive"
82 -#endif
83 -
84 -#ifdef USE_WAITPID
85 -#define WAIT_TRIES 100
86 -#define WAIT_MSEC 5000
87 -#endif
88 -
89 -#ifndef WAIT_MSEC
90 -#define WAIT_MSEC 5000
91 -#endif
92 -
93 -static pid_t _launchpid=0;
94 -
95 -/* spawnvp seems to be broken on cygwin as of 1/06, so just use fork/exec */
96 -#if HAVE_CYGWIN
97 -#define HAVE_CYGWIN_USE_SPAWNVP 0
98 -#endif
99 /*
100 *----------------------------------------------------------------------------
101 *
102 @@ -40,96 +14,104 @@
103 *----------------------------------------------------------------------------
104 */
105
106 -#if HAVE_CYGWIN||HAVE_MINGW32
107 +static pid_t pid=0;
108
109 +/* wait for child process to start, using waitpid() */
110 #ifdef ANSI_FUNC
111 -static int launch_win32(char *cmdstring, int attach, char **stdfiles)
112 +static int launch_pipes(int *pipes, int flag)
113 #else
114 -static int launch_win32(cmdstring, attach, stdfiles)
115 - char *cmdstring;
116 - int attach;
117 - char **stdfiles;
118 +static int launch_pipes(pipes, flag)
119 + int *pipes;
120 + int flag;
121 #endif
122 {
123 - int i, j;
124 - int len;
125 - int got;
126 - int status;
127 - char *argv[LAUNCHARGS+1];
128 - char *path=NULL;
129 - char *s=NULL, *t=NULL;
130 - struct timeval tv;
131 -
132 - /* for now, we can't support stdfiles */
133 - if( stdfiles )
134 - return(-1);
135 -
136 - /* package up the arguments for new process */
137 - t = (char *)xstrdup(cmdstring);
138 - for(i=0, got=0, s=(char *)strtok(t, " \t"); s;
139 - i++, s=(char *)strtok(NULL," \t")){
140 - if( i < LAUNCHARGS ){
141 - /* save argument */
142 - argv[i] = xstrdup(s);
143 - /* change back special char to spaces, if necessary */
144 - len = strlen(argv[i]);
145 - for(j=0; j<len; j++){
146 - if( argv[i][j] == LAUNCH_SPACE){
147 - argv[i][j] = ' ';
148 - }
149 - }
150 - argv[i+1] = NULL;
151 - /* save program name */
152 - if( i == 0 ) path = (char *)argv[i];
153 - got++;
154 - }
155 + int i;
156 + char tbuf[SZ_LINE];
157 + if( pipes ){
158 + for(i=0; i<4; i++){
159 + pipes[i] = -1;
160 + }
161 + if( (pipe(&pipes[0]) < 0) || (pipe(&pipes[2]) < 0) ) return -1;
162 + if( flag ){
163 +#if HAVE_SETENV
164 + snprintf(tbuf, SZ_LINE-1, "%d,%d,%d,%d",
165 + pipes[0], pipes[1], pipes[2], pipes[3]);
166 + setenv("LAUNCH_PIPES", tbuf, 1);
167 +#else
168 + snprintf(tbuf, SZ_LINE-1, "LAUNCH_PIPES=%d,%d,%d,%d",
169 + pipes[0], pipes[1], pipes[2], pipes[3]);
170 + putenv(xstrdup(tbuf));
171 +#endif
172 }
173 - if( t ) xfree(t);
174 - if( attach )
175 - i = _P_WAIT;
176 - else
177 - i = _P_NOWAIT;
178 - if((status = spawnvp(i, path, (void *)argv)) != -1){
179 - status = 0;
180 - /* wait for child to start */
181 - tv.tv_sec = 0;
182 - tv.tv_usec = WAIT_MSEC;
183 - xselect(1, NULL, NULL, NULL, &tv);
184 }
185 - for(i=0; i<got; i++)
186 - if( argv[i] ) xfree((char *)argv[i]);
187 - return(status);
188 + return 0;
189 }
190
191 +#ifdef ANSI_FUNC
192 +static int cleanup_pipes(int *pipes)
193 +#else
194 +static int cleanup_pipes(pipes)
195 + int *pipes;
196 #endif
197 +{
198 + if( pipes ){
199 + /* close child pipes */
200 + close(pipes[1]);
201 + close(pipes[2]);
202 + /* move parent write into slot 1 */
203 + pipes[1] = pipes[3];
204 + /* set unused pipes to impossible value */
205 + pipes[2] = -1;
206 + pipes[3] = -1;
207 + }
208 + return 0;
209 +}
210
211 -/*
212 - *----------------------------------------------------------------------------
213 - *
214 - *
215 - * Public Routines and Data
216 - *
217 - *
218 - *----------------------------------------------------------------------------
219 - */
220 -
221 -/*
222 - *
223 - * launchpid() -- return pid of last launched process
224 - *
225 - */
226 +#if LAUNCH_USE_WAITPID
227 +/* wait for child process to start, using waitpid() */
228 #ifdef ANSI_FUNC
229 -pid_t launchpid(void)
230 +static int launch_waitstart(pid_t pid)
231 #else
232 -pid_t launchpid()
233 +static int launch_waitstart(pid)
234 + pid_t pid;
235 #endif
236 {
237 - return _launchpid;
238 + int i, got;
239 + int status=0;
240 + struct timeval tv;
241 + /* wait up to LAUNCH_WAIT_TRIES millisec to make sure the child started,
242 + but if we get an error, we can exit immediately */
243 + for(i=0; i<LAUNCH_WAIT_TRIES; i++){
244 + errno = 0;
245 + got=waitpid(pid, &status, WNOHANG);
246 + /* look for error termination */
247 + if( (got < 0) || ((got == 0) && xerrno) ){
248 + got = -1;
249 + /* make sure status shows error */
250 + if( status == 0 )
251 + status = -1;
252 + break;
253 }
254 -
255 -#if HAVE_MINGW32==0
256 + /* look for normal termination */
257 + else if( got > 0 ){
258 + break;
259 + }
260 + /* no termination, sleep and wait some more */
261 + else{
262 + tv.tv_sec = 0;
263 + tv.tv_usec = LAUNCH_WAIT_MSEC;
264 + xselect(1, NULL, NULL, NULL, &tv);
265 + }
266 + }
267 + /* no termination means the child is still running */
268 + if( got == 0 ) status = 0;
269 + /* return the news */
270 + return status;
271 +}
272 +#endif
273
274 /*
275 + * standard unix version of launch:
276 * adapted from the system() code in:
277 * W. Richard Stevens
278 * "Advanced Programming in the Unix Environment"
279 @@ -137,71 +119,86 @@
280 * p. 314
281 */
282 #ifdef ANSI_FUNC
283 -int launch(char *cmdstring, int attach, char **stdfiles)
284 +static int launch_fork_exec(char *cmdstring, int attach,
285 + char **stdfiles, int *pipes)
286 #else
287 -int launch(cmdstring, attach, stdfiles)
288 + static int launch_fork_exec(cmdstring, attach, stdfiles, pipes)
289 char *cmdstring;
290 int attach;
291 char **stdfiles;
292 + int *pipes;
293 #endif
294 {
295 int status;
296 - pid_t pid;
297 + int tpipes[4];
298 struct sigaction ignore, saveintr, savequit;
299 sigset_t chldmask, savemask;
300 -#ifdef USE_PIPE
301 +#if LAUNCH_USE_PIPE
302 int fd[2];
303 #endif
304
305 /* return false if no command is specified */
306 - if( !cmdstring || !*cmdstring )
307 - return(-1);
308 + if( !cmdstring || !*cmdstring ) return -1;
309
310 ignore.sa_handler = SIG_IGN; /* ignore SIGINT and SIGQUIT */
311 sigemptyset(&ignore.sa_mask);
312 ignore.sa_flags = 0;
313 if (sigaction(SIGINT, &ignore, &saveintr) < 0)
314 - return(-1);
315 + return -1;
316 if (sigaction(SIGQUIT, &ignore, &savequit) < 0)
317 - return(-1);
318 + return -1;
319
320 sigemptyset(&chldmask); /* now block SIGCHLD */
321 sigaddset(&chldmask, SIGCHLD);
322 if (sigprocmask(SIG_BLOCK, &chldmask, &savemask) < 0)
323 - return(-1);
324 + return -1;
325
326 -#if HAVE_CYGWIN_USE_SPAWNVP
327 - /* if we are on the Cygwin platform, use fork/exec only if we are
328 - redirecting stdfiles. Otherwise use spawnvp(), which works better. */
329 - if( stdfiles ){
330 -#endif
331 -
332 -#ifdef USE_PIPE
333 +#if LAUNCH_USE_PIPE
334 /* open a pipe so parent can hear if the child fails to exec */
335 if( !attach ){
336 if( pipe(fd) < 0 )
337 - return(-1);
338 + return -1;
339 xfcntl(fd[0], F_SETFD, FD_CLOEXEC);
340 xfcntl(fd[1], F_SETFD, FD_CLOEXEC);
341 }
342 #endif
343
344 + /* create temp ipc pipes if necessary */
345 + if( pipes ){
346 + if( launch_pipes(tpipes, 0) < 0 ) return -1;
347 + }
348 +
349 /* start new process */
350 if( (pid = fork()) < 0 ){
351 -#ifdef USE_PIPE
352 +#if LAUNCH_USE_PIPE
353 if( !attach ){
354 close(fd[0]);
355 close(fd[1]);
356 }
357 #endif
358 + if( pipes ){
359 + close(tpipes[0]);
360 + close(tpipes[1]);
361 + close(tpipes[2]);
362 + close(tpipes[3]);
363 + }
364 status = -1; /* ERROR: probably out of processes */
365 -
366 } else if( pid == 0 ){ /* child */
367 int i, j, len;
368 - char *argv[LAUNCHARGS+1];
369 + char *argv[LAUNCH_ARGS+1];
370 char *path=NULL;
371 char *s=NULL, *t=NULL;
372
373 + /* reset pipes, if necessary */
374 + if( pipes ){
375 + /* close parent's read/write pipes */
376 + close(tpipes[0]);
377 + close(tpipes[3]);
378 + /* change child's stdin/stdout to use the passed pipes to parent */
379 + dup2(tpipes[2], 0); close(tpipes[2]);
380 + dup2(tpipes[1], 1); close(tpipes[1]);
381 + }
382 +
383 /* close and reopen stdio files, if necessary */
384 if( stdfiles ){
385 for(i=0; i<3; i++){
386 @@ -241,7 +238,7 @@
387 sigaction(SIGQUIT, &savequit, NULL);
388 sigprocmask(SIG_SETMASK, &savemask, NULL);
389 }
390 -#ifdef USE_PIPE
391 +#if LAUNCH_USE_PIPE
392 /* child closes reader -- only writes status */
393 else{
394 close(fd[0]);
395 @@ -252,7 +249,7 @@
396 t = (char *)xstrdup(cmdstring);
397 for(i=0, s=(char *)strtok(t, " \t"); s;
398 i++, s=(char *)strtok(NULL," \t")){
399 - if( i < LAUNCHARGS ){
400 + if( i < LAUNCH_ARGS ){
401 /* save argument */
402 argv[i] = xstrdup(s);
403 /* change back special char to spaces, if necessary */
404 @@ -278,7 +275,7 @@
405 /* start up the new program */
406 if( execvp(path, argv) ){
407 status = 127;
408 -#ifdef USE_PIPE
409 +#if LAUNCH_USE_PIPE
410 if( !attach ){
411 write(fd[1], &status, 4);
412 close(fd[1]);
413 @@ -287,7 +284,6 @@
414 _exit(status); /* exec error */
415 }
416 } else { /* parent */
417 - _launchpid = pid;
418 /* wait for program termination from attached process */
419 if( attach ){
420 while( waitpid(pid, &status, 0) < 0 ){
421 @@ -298,38 +294,10 @@
422 }
423 }
424 else{
425 -#ifdef USE_WAITPID
426 - int i, got;
427 - struct timeval tv;
428 - /* we wait up to WAIT_TRIES millisecs to make sure the child started;
429 - but if we get an error, we can exit immediately */
430 - for(i=0; i<WAIT_TRIES; i++){
431 - errno = 0;
432 - got=waitpid(pid, &status, WNOHANG);
433 - /* look for error termination */
434 - if( (got < 0) || ((got == 0) && xerrno) ){
435 - got = -1;
436 - /* make sure status shows error */
437 - if( status == 0 )
438 - status = -1;
439 - break;
440 - }
441 - /* look for normal termination */
442 - else if( got > 0 ){
443 - break;
444 - }
445 - /* no termination, sleep and wait some more */
446 - else{
447 - tv.tv_sec = 0;
448 - tv.tv_usec = WAIT_MSEC;
449 - xselect(1, NULL, NULL, NULL, &tv);
450 - }
451 - }
452 - /* no termination means the child is still running */
453 - if( got == 0 )
454 - status = 0;
455 +#if LAUNCH_USE_WAITPID
456 + status = launch_waitstart(pid);
457 #endif
458 -#ifdef USE_PIPE
459 +#if LAUNCH_USE_PIPE
460 close(fd[1]);
461 if( read(fd[0], &status, 4) == 0 ){
462 status = 0;
463 @@ -339,37 +307,321 @@
464 }
465 }
466
467 -#if HAVE_CYGWIN_USE_SPAWNVP
468 + /* cleanup temp ipc pipes and move into user space */
469 + if( pipes ){
470 + cleanup_pipes(tpipes);
471 + pipes[0] = tpipes[0];
472 + pipes[1] = tpipes[1];
473 + }
474 +
475 + /* restore previous signal actions & reset signal mask */
476 + if( sigaction(SIGINT, &saveintr, NULL) < 0 ) return -1;
477 + if( sigaction(SIGQUIT, &savequit, NULL) < 0 ) return -1;
478 + if( sigprocmask(SIG_SETMASK, &savemask, NULL) < 0 ) return -1;
479 +
480 + /* return the news */
481 + return status;
482 +}
483 +
484 +#if HAVE_POSIX_SPAWN
485 +
486 +extern char **environ;
487 +
488 +/* spawn calls POSIX posix_spawn */
489 +#ifdef ANSI_FUNC
490 +static int launch_posix_spawn(char *cmdstring, int attach,
491 + char **stdfiles, int *pipes)
492 +#else
493 + static int launch_posix_spawn(cmdstring, attach, stdfiles, pipes)
494 + char *cmdstring;
495 + int attach;
496 + char **stdfiles;
497 + int *pipes;
498 +#endif
499 +{
500 + int i, j, len;
501 + int status=0;
502 + int got=0;
503 + int tpipes[4];
504 + char *argv[LAUNCH_ARGS+1];
505 + char *path=NULL;
506 + char *s=NULL, *t=NULL;
507 + posix_spawn_file_actions_t act;
508 + posix_spawn_file_actions_t *pact=NULL;
509 +
510 + /* return false if no command is specified */
511 + if( !cmdstring || !*cmdstring )
512 + return -1;
513 +
514 + /* create temp ipc pipes if necessary */
515 + if( pipes ){
516 + if( launch_pipes(tpipes, 1) < 0 ) return -1;
517 + }
518 +
519 + /* package up the arguments for new process */
520 + t = (char *)xstrdup(cmdstring);
521 + for(i=0, s=(char *)strtok(t, " \t"); s;
522 + i++, s=(char *)strtok(NULL," \t")){
523 + if( i < LAUNCH_ARGS ){
524 + /* save argument */
525 + argv[i] = xstrdup(s);
526 + /* change back special char to spaces, if necessary */
527 + len = strlen(argv[i]);
528 + for(j=0; j<len; j++){
529 + if( argv[i][j] == LAUNCH_SPACE){
530 + argv[i][j] = ' ';
531 + }
532 + }
533 + /* last arg is always a NULL */
534 + argv[i+1] = NULL;
535 + /* save program name */
536 + if( i == 0 ) path = argv[i];
537 + /* inc arg count */
538 + got++;
539 }
540 - /* for Cygwin, call their spawnvp() routine instead of fork()/exec() */
541 + }
542 + if( t ) xfree(t);
543 + /* arrange stdfiles files, if necessary */
544 + if( stdfiles ){
545 + if( posix_spawn_file_actions_init(&act) != 0)
546 + return -1;
547 + /* stdin */
548 + if(stdfiles[0] &&
549 + posix_spawn_file_actions_addopen(&act, 0, stdfiles[0], O_RDONLY, 0))
550 + return -1;
551 + /* stdout */
552 + if(stdfiles[1] &&
553 + posix_spawn_file_actions_addopen(&act, 1, stdfiles[1], O_CREAT|O_WRONLY|O_TRUNC, 0600))
554 + return -1;
555 + /* stderr */
556 + if(stdfiles[2] &&
557 + posix_spawn_file_actions_addopen(&act, 2, stdfiles[2], O_CREAT|O_WRONLY|O_TRUNC, 0600))
558 + return -1;
559 + pact = &act;
560 + }
561 + /* start the new process */
562 + if( (status = posix_spawnp(&pid, path, pact, NULL, argv, environ)) )
563 + return status;
564 + /* wait for program termination from attached process */
565 + if( attach ){
566 + while( waitpid(pid, &status, 0) < 0 ){
567 + if( xerrno != EINTR ){
568 + status = -1; /* error other than EINTR from waitpid() */
569 + break;
570 + }
571 + }
572 + }
573 +#if BIG_DELAY_WHEN_USING_THIS
574 + /* wait for child process to start */
575 else{
576 - status = launch_win32(cmdstring, attach, stdfiles);
577 + status = launch_waitstart(pid);
578 + }
579 +#endif
580 + /* clean up */
581 + if( stdfiles ) posix_spawn_file_actions_destroy(&act);
582 + /* cleanup temp ipc pipes and move into user space */
583 + if( pipes ){
584 + cleanup_pipes(tpipes);
585 + pipes[0] = tpipes[0];
586 + pipes[1] = tpipes[1];
587 + }
588 + for(i=0; i<got; i++){
589 + if( argv[i] ) xfree((char *)argv[i]);
590 + }
591 + /* return status */
592 + return status;
593 }
594 +
595 #endif
596
597 - /* restore previous signal actions & reset signal mask */
598 - if( sigaction(SIGINT, &saveintr, NULL) < 0 )
599 - return(-1);
600 - if( sigaction(SIGQUIT, &savequit, NULL) < 0 )
601 - return(-1);
602 - if( sigprocmask(SIG_SETMASK, &savemask, NULL) < 0 )
603 - return(-1);
604 +#if HAVE_SPAWNVP
605 +
606 +#ifdef ANSI_FUNC
607 +static int launch_spawnvp(char *cmdstring, int attach,
608 + char **stdfiles, int *pipes)
609 +#else
610 + static int launch_spawnvp(cmdstring, attach, stdfiles, pipes)
611 + char *cmdstring;
612 + int attach;
613 + char **stdfiles;
614 + int *pipes;
615 +#endif
616 +{
617 + int i, j;
618 + int len;
619 + int got;
620 + int status;
621 + int tpipes[4];
622 + char *argv[LAUNCH_ARGS+1];
623 + char *path=NULL;
624 + char *s=NULL, *t=NULL;
625 + struct timeval tv;
626 +
627 + /* return false if no command is specified */
628 + if( !cmdstring || !*cmdstring ) return -1;
629 +
630 + /* for now, we can't support stdfiles */
631 + if( stdfiles ) return -1;
632
633 - return(status);
634 + /* create temp ipc pipes if necessary */
635 + if( pipes ){
636 + if( launch_pipes(tpipes, 1) < 0 ) return -1;
637 + }
638 +
639 + /* package up the arguments for new process */
640 + t = (char *)xstrdup(cmdstring);
641 + for(i=0, got=0, s=(char *)strtok(t, " \t"); s;
642 + i++, s=(char *)strtok(NULL," \t")){
643 + if( i < LAUNCH_ARGS ){
644 + /* save argument */
645 + argv[i] = xstrdup(s);
646 + /* change back special char to spaces, if necessary */
647 + len = strlen(argv[i]);
648 + for(j=0; j<len; j++){
649 + if( argv[i][j] == LAUNCH_SPACE){
650 + argv[i][j] = ' ';
651 + }
652 }
653 + /* last arg is always a NULL */
654 + argv[i+1] = NULL;
655 + /* save program name */
656 + if( i == 0 ) path = (char *)argv[i];
657 + /* inc arg count */
658 + got++;
659 + }
660 + }
661 + if( t ) xfree(t);
662 + if( attach )
663 + i = _P_WAIT;
664 + else
665 + i = _P_NOWAIT;
666 + if((status = spawnvp(i, path, (void *)argv)) != -1){
667 + status = 0;
668 + /* wait for child to start */
669 + tv.tv_sec = 0;
670 + tv.tv_usec = LAUNCH_WAIT_MSEC;
671 + xselect(1, NULL, NULL, NULL, &tv);
672 + }
673 + /* clean up */
674 + for(i=0; i<got; i++){
675 + if( argv[i] ) xfree((char *)argv[i]);
676 + }
677 + /* cleanup temp ipc pipes and move into user space */
678 + if( pipes ){
679 + cleanup_pipes(tpipes);
680 + pipes[0] = tpipes[0];
681 + pipes[1] = tpipes[1];
682 + }
683 + return status;
684 +}
685 +
686 +#endif
687
688 +/*
689 + *----------------------------------------------------------------------------
690 + *
691 + *
692 + * Public Routines and Data
693 + *
694 + *
695 + *----------------------------------------------------------------------------
696 + */
697 +
698 +/*
699 + *
700 + * LaunchPid() -- return pid of last launched process
701 + *
702 + */
703 +#ifdef ANSI_FUNC
704 +pid_t LaunchPid(void)
705 #else
706 +pid_t LaunchPid()
707 +#endif
708 +{
709 + return pid;
710 +}
711
712 #ifdef ANSI_FUNC
713 -int launch(char *cmdstring, int attach, char **stdfiles)
714 +int Launch(char *cmdstring, int attach, char **stdfiles, int *pipes)
715 #else
716 -int launch(cmdstring, attach, stdfiles)
717 +int Launch(cmdstring, attach, stdfiles, piles)
718 char *cmdstring;
719 int attach;
720 char **stdfiles;
721 + int *pipes;
722 #endif
723 {
724 - return launch_win32(cmdstring, attach, stdfiles);
725 + static int which_launch=0;
726 + static int which_debug=0;
727 + char *s=NULL;
728 +
729 + /* return false if no command is specified */
730 + if( !cmdstring || !*cmdstring ) return -1;
731 +
732 + /* sanity check: don't specify stdfiles and pipes simultaneously */
733 + if( stdfiles && pipes ){
734 + fprintf(stderr,
735 + "ERROR: stdfiles and pipes are mutually exclusive in Launch()\n");
736 + return -1;
737 }
738
739 + /* if pipes are specified, we don't attach */
740 + if( pipes ) attach = 0;
741 +
742 + /* determine launch method */
743 + if( !which_launch ){
744 + which_launch = LAUNCH_DEFAULT_WHICH;
745 + if( (s=getenv("LAUNCH_ROUTINE")) ){
746 + /* fork_exec */
747 + if( !strncasecmp(s, "f", 1) ){
748 + which_launch = 1;
749 + if( *s == 'F' ) which_debug = 1;
750 + }
751 + /* posix_spawn */
752 + else if( !strncasecmp(s, "p", 1) ){
753 + which_launch = 2;
754 + if( *s == 'P' ) which_debug = 1;
755 + }
756 + /* spawnvp */
757 + else if( !strncasecmp(s, "s", 1) ){
758 + which_launch = 3;
759 + if( *s == 'S' ) which_debug = 1;
760 + }
761 + else if( *s == 'V' ) {
762 + which_debug = 1;
763 + }
764 + }
765 + }
766 + /* call the correct launch method */
767 + switch(which_launch){
768 + case 1:
769 + if( which_debug ) fprintf(stderr, "launch_fork_exec: %s\n", cmdstring);
770 + return launch_fork_exec(cmdstring, attach, stdfiles, pipes);
771 + break;
772 + case 2:
773 +#if HAVE_POSIX_SPAWN
774 + if( which_debug ) fprintf(stderr, "launch_posix_spawn: %s\n", cmdstring);
775 + return launch_posix_spawn(cmdstring, attach, stdfiles, pipes);
776 +#else
777 + fprintf(stderr, "ERROR: posix_spawn() not available on this host\n");
778 + exit(1);
779 #endif
780 + break;
781 + case 3:
782 +#if HAVE_SPAWNVP
783 + if( which_debug ) fprintf(stderr, "launch_spawnvp: %s\n", cmdstring);
784 + return launch_spawnvp(cmdstring, attach, stdfiles, pipes);
785 +#else
786 + fprintf(stderr, "ERROR: spawnvp() not available on this host\n");
787 + exit(1);
788 +#endif
789 + break;
790 + default:
791 + if( which_debug ) fprintf(stderr, "launch_fork_exec: %s\n", cmdstring);
792 + return launch_fork_exec(cmdstring, attach, stdfiles, pipes);
793 + break;
794 + }
795 + /* can't happen */
796 + return -1;
797 +}
798 +
799 --- xpa-2.1.8.orig/launch.h 2006-01-27 16:25:08.000000000 +0000
800 +++ xpa-2.1.8/launch.h 2007-12-18 20:09:26.000000000 +0000
801 @@ -30,17 +30,54 @@
802 #if HAVE_UNISTD_H
803 #include <unistd.h>
804 #endif
805 +#if HAVE_POSIX_SPAWN
806 +#include <spawn.h>
807 +#endif
808 #include <xport.h>
809 #include <word.h>
810 #include <xalloc.h>
811 #include <prsetup.h>
812
813 +#define LAUNCH_ARGS 1024
814 +
815 #define LAUNCH_SPACE '\001'
816
817 +/* for fork/exec, one of these is required to specify the technique to be used
818 + by the parent when determining if the child started successfully */
819 +#if !defined(LAUNCH_USE_PIPE) && !defined(LAUNCH_USE_WAITPID)
820 +#define LAUNCH_USE_PIPE 1
821 +#endif
822 +/* ... but not both */
823 +#if defined(LAUNCH_USE_PIPE) && defined(LAUNCH_USE_WAITPID)
824 +#error "LAUNCH_USE_PIPE and LAUNCH_USE_WAITPID are mutually exclusive"
825 +#endif
826 +
827 +#ifndef LAUNCH_WAIT_TRIES
828 +#define LAUNCH_WAIT_TRIES 100
829 +#endif
830 +#ifndef LAUNCH_WAIT_MSEC
831 +#define LAUNCH_WAIT_MSEC 5000
832 +#endif
833 +
834 +#if HAVE_MINGW32|HAVE_CYGWIN
835 +#define HAVE_SPAWNVP 1
836 +#endif
837 +
838 +#if HAVE_MINGW32
839 +/* for now, ensure that MinGW utilizes spawnvp() */
840 +#define LAUNCH_DEFAULT_WHICH 3
841 +#elif HAVE_POSIX_SPAWN
842 +/* use posix_spawn if possible (required for OS X 10.5) */
843 +#define LAUNCH_DEFAULT_WHICH 2
844 +#else
845 +/* use our home-grown version */
846 +#define LAUNCH_DEFAULT_WHICH 1
847 +#endif
848 +
849 _PRbeg
850
851 -int launch _PRx((char *cmdstring, int wait, char **stdfiles));
852 -pid_t launchpid _PRx((void));
853 +int Launch _PRx((char *cmdstring, int wait, char **stdfiles, int *pipes));
854 +pid_t LaunchPid _PRx((void));
855
856 _PRend
857
858 --- xpa-2.1.8.orig/xpa.c 2007-03-21 16:29:18.000000000 +0000
859 +++ xpa-2.1.8/xpa.c 2007-12-18 20:09:26.000000000 +0000
860 @@ -684,7 +684,7 @@
861 if((*nscmd != '\0') && ((mtype == XPA_UNIX) || LOCALIP(xnsip)) ){
862 FPRINTF((stderr, "%sLaunching: %s\n", _sp, nscmd));
863 #if USE_LAUNCH
864 - if( launch(nscmd, 0, NULL) != 0 )
865 + if( Launch(nscmd, 0, NULL, NULL) != 0 )
866 goto nons;
867 #else
868 if( system(nscmd) != 0 )
869 --- xpa-2.1.8.orig/xpap.h 2006-01-27 16:13:28.000000000 +0000
870 +++ xpa-2.1.8/xpap.h 2007-12-18 20:09:26.000000000 +0000
871 @@ -15,7 +15,9 @@
872 #endif
873
874 /* avoid use of system -- its not secure */
875 +#if USE_SPAWN == 0
876 #define USE_LAUNCH 1
877 +#endif
878
879 #if HAVE_UNISTD_H
880 #include <unistd.h>
881
882
883
884 1.1 x11-libs/xpa/files/xpa-2.1.8-makefile.patch
885
886 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-libs/xpa/files/xpa-2.1.8-makefile.patch?rev=1.1&view=markup
887 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-libs/xpa/files/xpa-2.1.8-makefile.patch?rev=1.1&content-type=text/plain
888
889 Index: xpa-2.1.8-makefile.patch
890 ===================================================================
891 --- Makefile.in.orig 2008-11-03 12:05:33.000000000 +0000
892 +++ Makefile.in 2008-11-03 12:07:48.000000000 +0000
893 @@ -28,6 +28,11 @@
894
895 prefix = @prefix@
896 exec_prefix = @exec_prefix@
897 +bindir = @bindir@
898 +libdir = @libdir@
899 +datadir = @datadir@
900 +mandir = @mandir@
901 +includedir = @includedir@
902
903 # The following definition can be set to non-null for special systems
904 # like AFS with replication. It allows the pathnames used for installation
905 @@ -37,19 +42,19 @@
906 INSTALL_ROOT =
907
908 # Directory in which to install the .a or .so binary for the XPA library:
909 -LIB_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/lib
910 +LIB_INSTALL_DIR = $(INSTALL_ROOT)$(libdir)
911
912 # Directory in which to install the program wish:
913 -BIN_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/bin
914 +BIN_INSTALL_DIR = $(INSTALL_ROOT)$(bindir)
915
916 # Directory in which to install the include file xpa.h:
917 -INCLUDE_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/include
918 +INCLUDE_INSTALL_DIR = $(INSTALL_ROOT)$(includedir)
919
920 # Top-level directory for manual entries:
921 -MAN_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/man
922 +MAN_INSTALL_DIR = $(INSTALL_ROOT)$(mandir)
923
924 # Top-level directory for share entries:
925 -MAN_SHARE_DIR = $(INSTALL_ROOT)$(prefix)/share/xpa
926 +MAN_SHARE_DIR = $(INSTALL_ROOT)$(datadir)/xpa
927
928 # Platform-specific X compiler flags (include file specifications)
929 X_CFLAGS = @X_CFLAGS@
930 @@ -175,7 +180,7 @@
931 $(RANLIB) $(LIB)
932
933 shlib: $(LIB)
934 - @(rm -rf lib$(PACKAGE).tmp; mkdir lib$(PACKAGE).tmp; \
935 + @(rm -rf lib$(PACKAGE).tmp; mkdir -p lib$(PACKAGE).tmp; \
936 (cd lib$(PACKAGE).tmp && ar x ../lib$(PACKAGE).a); \
937 rm -f lib$(PACKAGE).tmp/xt*.o; \
938 rm -f lib$(PACKAGE).tmp/tcl*.o; \
939 @@ -184,7 +189,7 @@
940 rm -rf lib$(PACKAGE).tmp)
941
942 tclxpa: $(LIB)
943 - @(rm -rf libtclxpa.tmp; mkdir libtclxpa.tmp; \
944 + @(rm -rf libtclxpa.tmp; mkdir -p libtclxpa.tmp; \
945 (cd libtclxpa.tmp && ar x ../lib$(PACKAGE).a); \
946 rm -f libtclxpa.tmp/xt*.o; \
947 CC='$(CC)' CXX=$(CXX) \
948 @@ -259,7 +264,7 @@
949 do \
950 if [ ! -d $$i ] ; then \
951 echo "Making directory $$i"; \
952 - mkdir $$i; \
953 + mkdir -p $$i; \
954 chmod 755 $$i; \
955 else true; \
956 fi; \
957 @@ -281,7 +286,7 @@
958 install-man:
959 @if [ ! -d $(MAN_INSTALL_DIR) ] ; then \
960 echo "Making directory $(MAN_INSTALL_DIR)"; \
961 - mkdir $(MAN_INSTALL_DIR); \
962 + mkdir -p $(MAN_INSTALL_DIR); \
963 chmod 755 $(MAN_INSTALL_DIR); \
964 else true; \
965 fi;
966 @@ -292,7 +297,7 @@
967 M="$(MAN_INSTALL_DIR)/man$$E"; \
968 if [ ! -d $$M ] ; then \
969 echo "Making directory $$M"; \
970 - mkdir $$M; \
971 + mkdir -p $$M; \
972 chmod 755 $$M; \
973 else true; \
974 fi; \