home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
dmake40.zip
/
msdos
/
runargv.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-23
|
3KB
|
115 lines
/* RCS -- $Header: /u5/dvadura/src/public/dmake/src/msdos/RCS/runargv.c,v 1.1 1994/10/06 17:41:45 dvadura Exp $
-- SYNOPSIS -- run a sub process.
--
-- DESCRIPTION
-- Use spawn to run a subprocess.
--
-- AUTHOR
-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca
-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada
--
-- COPYRIGHT
-- Copyright (c) 1992,1994 by Dennis Vadura. All rights reserved.
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- (version 1), as published by the Free Software Foundation, and
-- found in the file 'LICENSE' included with this distribution.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warrant of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--
-- LOG
-- $Log: runargv.c,v $
* Revision 1.1 1994/10/06 17:41:45 dvadura
* dmake Release Version 4.0, Initial revision
*
*/
#include <process.h>
#include <errno.h>
#include "extern.h"
#include "sysintf.h"
static int _abort_flg = FALSE;
static void _add_child ANSI((CELLPTR, int));
static void _finished_child ANSI((int));
PUBLIC int
runargv(target, ignore, group, last, shell, cmd)
CELLPTR target;
int ignore;
int group;
int last;
int shell;
char *cmd;
{
#if ! defined(_MSC_VER)
extern char **environ;
#endif
int status;
char **argv;
argv = Pack_argv( group, shell, cmd );
_add_child(target, ignore);
status = spawnvpe(P_WAIT, *argv, argv, environ);
if( status == -1 ) Error("%s: %s", argv[0], strerror(errno));
_finished_child(status);
if( last && !Doing_bang ) Update_time_stamp( target );
return( 0 );
}
PUBLIC void
Clean_up_processes()
{
_abort_flg = TRUE;
_finished_child(-1);
}
PUBLIC int
Wait_for_child( abort_flg, pid )
int abort_flg;
int pid;
{
return(1);
}
static int _valid = -1;
static CELLPTR _tg;
static int _ignore;
static void
_add_child( target, ignore )
CELLPTR target;
int ignore;
{
_tg = target;
_ignore = ignore;
_valid = 0;
Current_target = NIL(CELL);
}
static void
_finished_child(status)
int status;
{
if( _valid == -1 ) return;
Unlink_temp_files( _tg );
_valid = -1;
Handle_result( status, _ignore, _abort_flg, _tg );
}