Commit 6cd88fe6 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Add spawnvp to the portability lib.

parent 17480acb
......@@ -250,6 +250,16 @@ extern void *memcpy_unaligned( void *dst, const void *src, size_t size );
extern int mkstemps(char *template, int suffix_len);
/* Process creation flags */
#ifndef _P_WAIT
# define _P_WAIT 0
# define _P_NOWAIT 1
# define _P_OVERLAY 2
# define _P_NOWAITO 3
# define _P_DETACH 4
#endif
extern int spawnvp(int mode, const char *cmdname, char *const argv[]);
/* Interlocked functions */
#if defined(__i386__) && defined(__GNUC__)
......@@ -321,6 +331,7 @@ extern long interlocked_xchg_add( long *dest, long incr );
#define memmove __WINE_NOT_PORTABLE(memmove)
#define pread __WINE_NOT_PORTABLE(pread)
#define pwrite __WINE_NOT_PORTABLE(pwrite)
#define spawnvp __WINE_NOT_PORTABLE(spawnvp)
#define statfs __WINE_NOT_PORTABLE(statfs)
#define strcasecmp __WINE_NOT_PORTABLE(strcasecmp)
#define strerror __WINE_NOT_PORTABLE(strerror)
......
......@@ -16,6 +16,7 @@ C_SRCS = \
mkstemps.c \
pread.c \
pwrite.c \
spawn.c \
statfs.c \
strcasecmp.c \
strerror.c \
......
/*
* 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 */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment