2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * A more convenient wrapper around WvSubProc. See wvsystem.h.
10 #include <sys/types.h>
18 void WvSystem::init(const char * const *argv
)
21 WvSubProc::preparev(argv
[0], argv
);
25 // open a given filename or device, making sure it has the given fd. If
26 // there is an open file on that fd already, it gets closed.
27 static void fd_open(int fd
, WvStringParm file
, int mode
)
30 int nfd
= ::open(file
, mode
, 0666);
41 // overrides WvSubProc::fork().
42 int WvSystem::fork(int *waitfd
)
44 int pid
= WvSubProc::fork(waitfd
);
47 if (!fdfiles
[0].isnull())
48 fd_open(0, fdfiles
[0], O_RDONLY
);
49 if (!fdfiles
[1].isnull())
50 fd_open(1, fdfiles
[1], O_WRONLY
|O_CREAT
);
51 if (!fdfiles
[2].isnull())
52 fd_open(2, fdfiles
[2], O_WRONLY
|O_CREAT
);
63 WvSubProc::start_again();
66 WvSubProc::wait(-1, false);
67 return WvSubProc::estatus
;
71 WvSystem
&WvSystem::infile(WvStringParm filename
)
73 fdfiles
[0] = filename
;
78 WvSystem
&WvSystem::outfile(WvStringParm filename
)
80 fdfiles
[1] = filename
;
85 WvSystem
&WvSystem::errfile(WvStringParm filename
)
87 fdfiles
[2] = filename
;