]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/otherlibs/unix/execvp.c
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / otherlibs / unix / execvp.c
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
6 /*                                                                     */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et   */
8 /*  en Automatique.  All rights reserved.  This file is distributed    */
9 /*  under the terms of the GNU Library General Public License, with    */
10 /*  the special exception on linking described in file ../../LICENSE.  */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: execvp.c 4144 2001-12-07 13:41:02Z xleroy $ */
15
16 #include <mlvalues.h>
17 #include <memory.h>
18 #include "unixsupport.h"
19
20 extern char ** cstringvect();
21 #ifndef _WIN32
22 extern char ** environ;
23 #endif
24
25 CAMLprim value unix_execvp(value path, value args)
26 {
27   char ** argv;
28   argv = cstringvect(args);
29   (void) execvp(String_val(path), argv);
30   stat_free((char *) argv);
31   uerror("execvp", path);
32   return Val_unit;                  /* never reached, but suppress warnings */
33                                 /* from smart compilers */
34 }
35
36 CAMLprim value unix_execvpe(value path, value args, value env)
37 {
38   char ** argv;
39   char ** saved_environ;
40   argv = cstringvect(args);
41   saved_environ = environ;
42   environ = cstringvect(env);
43   (void) execvp(String_val(path), argv);
44   stat_free((char *) argv);
45   stat_free((char *) environ);
46   environ = saved_environ;
47   uerror("execvp", path);
48   return Val_unit;                  /* never reached, but suppress warnings */
49                                 /* from smart compilers */
50 }
51