Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.5 KiB

  1. /***
  2. *execvp.c - execute a file and search along PATH
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _execvp() - execute a file and search along PATH
  8. *
  9. *Revision History:
  10. * 10-17-83 RN written
  11. * 10-29-85 TC added execvpe capability
  12. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  13. * 11-20-89 GJF Fixed copyright, indents. Added const attribute to
  14. * types of filename and argvector.
  15. * 03-08-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  16. * <cruntime.h> and removed #include <register.h>
  17. * 05-21-90 GJF Fixed stack checking pragma syntax.
  18. * 08-24-90 SBM Removed check_stack pragma since workhorse execve
  19. * does stack checks
  20. * 09-27-90 GJF New-style function declarator.
  21. * 01-17-91 GJF ANSI naming.
  22. * 02-14-90 SRW Use NULL instead of _environ to get default.
  23. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  24. * 12-07-93 CFW Wide char enable.
  25. * 02-06-98 GJF Changes for Win64: changed return type to intptr_t.
  26. *
  27. *******************************************************************************/
  28. #include <cruntime.h>
  29. #include <stdlib.h>
  30. #include <process.h>
  31. #include <tchar.h>
  32. /***
  33. *int _execvp(filename, argvector) - execute file; search along PATH
  34. *
  35. *Purpose:
  36. * Execute the given file with given path and current environ.
  37. * try to execute the file. start with the name itself (directory '.'),
  38. * and if that doesn't work start prepending pathnames from the
  39. * environment until one works or we run out. if the file is a pathname,
  40. * don't go to the environment to get alternate paths. if errno comes
  41. * back ENOEXEC, try it as a shell command file with up to MAXARGS-2
  42. * arguments from the original vector. if a needed text file is busy,
  43. * wait a little while and try again before despairing completely
  44. * Actually calls _execvpe() to do all the work.
  45. *
  46. *Entry:
  47. * _TSCHAR *filename - file to execute
  48. * _TSCHAR **argvector - vector of arguments
  49. *
  50. *Exit:
  51. * destroys the calling process (hopefully)
  52. * if fails, returns -1
  53. *
  54. *Exceptions:
  55. *
  56. *******************************************************************************/
  57. intptr_t __cdecl _texecvp (
  58. REG3 const _TSCHAR *filename,
  59. const _TSCHAR * const *argvector
  60. )
  61. {
  62. return _texecvpe( filename, argvector, NULL );
  63. }