Process and Environment Control
Use the process-control routines to start, stop, and manage processes from within a program. Use the environment-control routines to get and change information about the operating-system environment.
Process and Environment Control Functions
Routine |
Use |
.NET Framework equivalent |
---|---|---|
Abort process without flushing buffers or calling functions registered by atexit and _onexit |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Test for logic error |
||
_ASSERT, _ASSERTE macros |
Similar to assert, but only available in the debug versions of the run-time libraries |
|
Schedule routines for execution at program termination |
||
Create a new thread on a Windows operating system process |
||
Perform exit termination procedures (such as flushing buffers), then return control to calling program without terminating process |
||
Perform _exit termination procedures, then return control to calling program without terminating process |
||
Wait until another process terminates |
||
Terminate a Windows operating system thread |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Execute new process with argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process with argument list and given environment |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process using PATH variable and argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process using PATH variable, given environment, and argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process with argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process with argument array and given environment |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process using PATH variable and argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute new process using PATH variable, given environment, and argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Call functions registered by atexit and _onexit, flush all buffers, close all open files, and terminate process |
||
Terminate process immediately without calling atexit or _onexit or flushing buffers |
||
Get value of environment variable |
||
Get process ID number |
||
Restore saved stack environment; use it to execute a nonlocal goto |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Schedule routines for execution at program termination; use for compatibility with Microsoft C/C++ version 7.0 and earlier |
||
Wait for new command processor and close stream on associated pipe |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Print error message |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Create pipe for reading and writing |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Create pipe and execute command |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Add or change value of environment variable |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Send signal to calling process |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Save stack environment; use to execute non local goto |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Handle interrupt signal |
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples. |
|
Create and execute new process with specified argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process with specified argument list and environment |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process using PATH variable and specified argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process using PATH variable, specified environment, and argument list |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process with specified argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process with specified environment and argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process using PATH variable and specified argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Create and execute new process using PATH variable, specified environment, and argument array |
System::Diagnostics::Process Class, System::Diagnostics::ProcessStartInfo Class |
|
Execute operating-system command |
System::Diagnostics::ProcessStartInfo Class, System::Diagnostics::Process Class |
In the Windows operating system, the spawned process is equivalent to the spawning process. Any process can use _cwait to wait for any other process for which the process ID is known.
The difference between the _exec and _spawn families is that a _spawn function can return control from the new process to the calling process. In a _spawn function, both the calling process and the new process are present in memory unless _P_OVERLAY is specified. In an _exec function, the new process overlays the calling process, so control cannot return to the calling process unless an error occurs in the attempt to start execution of the new process.
The differences among the functions in the _exec family, as well as among those in the _spawn family, involve the method of locating the file to be executed as the new process, the form in which arguments are passed to the new process, and the method of setting the environment, as shown in the following table. Use a function that passes an argument list when the number of arguments is constant or is known at compile time. Use a function that passes a pointer to an array containing the arguments when the number of arguments is to be determined at run time. The information in the following table also applies to the wide-character counterparts of the _spawn and _exec functions.
_spawn and _exec Function Families
Functions |
Use PATH variable to locate file |
Argument-passing convention |
Environment settings |
---|---|---|---|
_execl, _spawnl |
No |
List |
Inherited from calling process |
_execle, _spawnle |
No |
List |
Pointer to environment table for new process passed as last argument |
_execlp, _spawnlp |
Yes |
List |
Inherited from calling process |
_execlpe, _spawnlpe |
Yes |
List |
Pointer to environment table for new process passed as last argument |
_execv, _spawnv |
No |
Array |
Inherited from calling process |
_execve, _spawnve |
No |
Array |
Pointer to environment table for new process passed as last argument |
_execvp, _spawnvp |
Yes |
Array |
Inherited from calling process |
_execvpe, _spawnvpe |
Yes |
Array |
Pointer to environment table for new process passed as last argument |