home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / exec / execle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-29  |  1.9 KB  |  82 lines

  1. /* 
  2.  * execle.c --
  3.  *
  4.  *    Source code for the execle library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: execle.c,v 1.4 88/07/28 17:41:50 ouster Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <stdlib.h>
  21. #include <varargs.h>
  22.  
  23. /*
  24.  * Library imports:
  25.  */
  26.  
  27. extern execve();
  28. extern char **_ExecArgs();
  29.  
  30.  
  31. /*
  32.  *----------------------------------------------------------------------
  33.  *
  34.  * execle --
  35.  *
  36.  *    Execute a process, using an explicitly-supplied environment, and
  37.  *    with arguments in-line (as individual parameters) instead of in
  38.  *    a separate array.
  39.  *
  40.  * Results:
  41.  *    This procedure returns only if the exec fails.  In this case
  42.  *    the return value is -1.
  43.  *
  44.  * Side effects:
  45.  *    Overlays the current process with a new image.  See the man
  46.  *    page for details.
  47.  *
  48.  *----------------------------------------------------------------------
  49.  */
  50.  
  51. #ifndef lint
  52. int
  53. execle(va_alist)
  54.     va_dcl            /* Name of file containing program to exec,
  55.                  * followed by one or more arguments of type
  56.                  * "char *", terminated by a zero argument,
  57.                  * followed by a "char **" environment
  58.                  * pointer. */
  59. {
  60.     char *name;
  61.     char **argv;
  62.     va_list args;
  63.  
  64.     va_start(args);
  65.     name = va_arg(args, char *);
  66.     argv = _ExecArgs(&args);
  67.     execve(name, argv, va_arg(args, char **));
  68.     free((char *) argv);
  69.     return -1;
  70. }
  71. #else
  72. /* VARARGS2 */
  73. /* ARGSUSED */
  74. int
  75. execl(file, arg1)
  76.     char *file;
  77.     char *arg1;
  78. {
  79.     return 0;
  80. }
  81. #endif
  82.