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.

72 lines
2.5 KiB

  1. /***
  2. *spawnv.c - spawn a child process
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _spawnv() - spawn a child process
  8. *
  9. *Revision History:
  10. * 04-15-84 DFW written
  11. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  12. * 11-20-89 GJF Fixed copyright, alignment. Added const to arg types
  13. * for pathname and argv.
  14. * 03-08-90 GJF Replace _LOAD_DS with _CALLTYPE1 and added #include
  15. * <cruntime.h>.
  16. * 07-24-90 SBM Removed redundant includes, replaced <assertm.h> by
  17. * <assert.h>
  18. * 09-27-90 GJF New-style function declarator.
  19. * 01-17-91 GJF ANSI naming.
  20. * 02-14-90 SRW Use NULL instead of _environ to get default.
  21. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  22. * 12-07-93 CFW Wide char enable.
  23. * 02-06-95 CFW assert -> _ASSERTE.
  24. * 02-06-98 GJF Changes for Win64: changed return type to intptr_t.
  25. *
  26. *******************************************************************************/
  27. #include <cruntime.h>
  28. #include <stdlib.h>
  29. #include <process.h>
  30. #include <tchar.h>
  31. #include <dbgint.h>
  32. /***
  33. *int _spawnv(modeflag, pathname, argv) - spawn a child process
  34. *
  35. *Purpose:
  36. * Spawns a child process.
  37. * formats the parameters and calls _spawnve to do the actual work. The
  38. * NULL environment pointer indicates that the new process will inherit
  39. * the parents process's environment. NOTE - at least one argument must
  40. * be present. This argument is always, by convention, the name of the
  41. * file being spawned.
  42. *
  43. *Entry:
  44. * int modeflag - mode to spawn (WAIT, NOWAIT, or OVERLAY)
  45. * only WAIT and OVERLAY currently implemented
  46. * _TSCHAR *pathname - file to spawn
  47. * _TSCHAR **argv - vector of arguments
  48. *
  49. *Exit:
  50. * returns exit code of child process
  51. * if fails, returns -1
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. intptr_t __cdecl _tspawnv (
  57. int modeflag,
  58. const _TSCHAR *pathname,
  59. const _TSCHAR * const *argv
  60. )
  61. {
  62. _ASSERTE(pathname != NULL);
  63. _ASSERTE(*pathname != _T('\0'));
  64. _ASSERTE(argv != NULL);
  65. _ASSERTE(*argv != NULL);
  66. _ASSERTE(**argv != _T('\0'));
  67. return(_tspawnve(modeflag,pathname,argv,NULL));
  68. }