On 1 Apr 2003, Alexandre Julliard wrote: > If they link with msvcrt then they are not supposed to use > wine/port.h. To avoid trouble with process.c I'd suggest naming the > function spawnvp, without the underscore prefix, and making it call > the real _spawnvp on Windows. Cool. Here it is again. I'll make use of it as soon as it gets into the tree. ChangeLog Add spawnvp to the portability lib. Index: include/wine/port.h =================================================================== RCS file: /var/cvs/wine/include/wine/port.h,v retrieving revision 1.36 diff -u -r1.36 port.h --- include/wine/port.h 28 Mar 2003 00:36:13 -0000 1.36 +++ include/wine/port.h 1 Apr 2003 17:24:48 -0000 @@ -211,6 +211,16 @@ ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset ); #endif /* HAVE_PWRITE */ +#ifndef HAVE__SPAWNVP +/* Process creation flags */ +#define _P_WAIT 0 +#define _P_NOWAIT 1 +#define _P_OVERLAY 2 +#define _P_NOWAITO 3 +#define _P_DETACH 4 +int spawnvp(int mode, const char *cmdname, char *const argv[]); +#endif /* HAVE__SPAWNVP */ + #ifndef HAVE_STATFS int statfs(const char *name, struct statfs *info); #endif /* !defined(HAVE_STATFS) */ Index: libs/port/Makefile.in =================================================================== RCS file: /var/cvs/wine/libs/port/Makefile.in,v retrieving revision 1.5 diff -u -r1.5 Makefile.in --- libs/port/Makefile.in 20 Mar 2003 23:44:36 -0000 1.5 +++ libs/port/Makefile.in 1 Apr 2003 05:20:57 -0000 @@ -16,6 +16,7 @@ mkstemps.c \ pread.c \ pwrite.c \ + spawn.c \ statfs.c \ strcasecmp.c \ strerror.c \ --- /dev/null 2002-08-30 19:31:37.000000000 -0400 +++ libs/port/spawn.c 2003-04-01 12:26:51.000000000 -0500 @@ -0,0 +1,53 @@ +/* + * spawnvp function + * + * Copyright 2003 Dimitrie O. Paun + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" +#include "wine/port.h" + +#include <errno.h> +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif +#include <sys/stat.h> +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +int spawnvp(int mode, const char *cmdname, char *const argv[]) +{ +#ifndef HAVE__SPAWNVP + int pid = 0, status, wret; + + if (mode != _P_OVERLAY) pid = fork(); + if (pid == 0) pid = execvp(argv[0], argv); + if (pid < 0) return -1; + + if (mode != _P_WAIT) return pid; + + while (pid != (wret = waitpid(pid, &status, 0))) + if (wret == -1 && errno != EINTR) break; + + if (pid == wret && WIFEXITED(status)) return WEXITSTATUS(status); + + return 255; /* abnormal exit with an abort or an interrupt */ +#else /* HAVE__SPAWNVP */ + return _spawnvp(mode, cmdname, argv); +#endif /* HAVE__SPAWNVP */ +} -- Dimi.