C process control: Difference between revisions

Content deleted Content added
readd reference to the C standard
Shorten Short description per WP:SDSHORT
 
(33 intermediate revisions by 21 users not shown)
Line 1:
{{Short description|Functions of the C standard software library}}
{{Use dmy dates|date=January 2022}}
{{C Standard Library}}
{{move to|C process control functions}}
 
'''C programprocess control operations''' arerefers to a group of functions in the [[C standard library|standard library]] of the [[C programming language]] implementing basic programprocess control operations.<ref>{{cite book|last=Crawford|first=Tony|coauthorsauthor2=Peter Prinz|title=C in a Nutshell|publisher=O'Reilly|___location=§16.11 - ''Process Control''|date=December 2005|pages=618|isbn=0-596-00697-7}}</ref><ref>{{cite book | url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf | title=ISO/IEC 9899:1999 specification | at=p. 315, § 7.20.4 "Communication with the environment" | accessdate=25 November 2011}}</ref> The process control operations include actions such as termination of the program with various levels of cleanup, running an external command interpreter or accessing the list of the environment operations.
| url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
| title=ISO/IEC 9899:1999 specification
| at=p. 315, § 7.20.4 "Communication with the environment"
}}</ref>
 
==Overview of functions==
 
The programprocess control functions are defined in the <ttcode>stdlib.h</ttcode> header (<ttcode>cstdlib</ttcode> header in C++).
 
{| class="wikitable" style="font-size:0.85em"
; Terminating a program
!
*<tt>{{man|sh|abort|SUS||inline}}</tt> - causes abnormal program termination (without cleaning up)
! Function
*<tt>{{man|sh|exit|SUS||inline}}</tt> - causes normal program termination with cleaning up
! Description
*<tt>{{man|sh|_Exit|SUS||inline}}</tt> - causes normal program termination without cleaning up
|-
*<tt>{{man|sh|atexit|SUS||inline}}</tt> - registers a function to be called on exit() invocation
;! rowspan=6 | Terminating <br>a program
 
| {{anchor|abort}}<code>[http://en.cppreference.com/w/c/program/abort abort]</code>
; Communicating with the environment
*<tt>{{man|sh|abort|SUS||inline}}</tt> - causes abnormal program termination (without cleaning up)
*<tt>{{man|sh|getenv|SUS||inline}}</tt> - accesses the list of the environment variables
|-
*<tt>{{man|sh|system|SUS||inline}}</tt> - calls the host environment's command processor
| {{anchor|exit}}<code>[http://en.cppreference.com/w/c/program/exit exit]</code>
*<tt>{{man|sh|exit|SUS||inline}}</tt> - causes normal program termination with cleaning up
|-
| {{anchor|_Exit}}<code>[http://en.cppreference.com/w/c/program/_Exit _Exit]</code>
*<tt>{{man|sh|_Exit|SUS||inline}}</tt> - causes normal program termination without cleaning up ([[C99]])
|-
| {{anchor|atexit}}<code>[http://en.cppreference.com/w/c/program/atexit atexit]</code>
*<tt>{{man|sh|atexit|SUS||inline}}</tt> - registers a function to be called on exit() invocation
|-
| {{anchor|quick_exit}}<code>[http://en.cppreference.com/w/c/program/quick_exit quick_exit]</code>
| causes normal program termination without cleaning up, but with IO buffers flushed ([[C11 (C standard revision)|C11]])
|-
| {{anchor|quick_exit}}<code>[http://en.cppreference.com/w/c/program/at_quick_exit at_quick_exit]</code>
| registers a function to be called on quick_exit() invocation
|-
;! rowspan=2 | Communicating with <br>the environment
| {{anchor|getenv}}<code>[http://en.cppreference.com/w/c/program/getenv getenv]</code>
*<tt>{{man|sh|getenv|SUS||inline}}</tt> - accesses the list of the environment variables
|-
| {{anchor|system}}<code>[http://en.cppreference.com/w/c/program/system system]</code>
*<tt>{{man|sh|system|SUS||inline}}</tt> - calls the host environment's command processor
|}
 
==References==
Line 26 ⟶ 45:
 
==External links==
{{wikibooks|C Programming|C program control operations|C Programming/C Reference}}
{{clear}}
 
[[Category:C Standardstandard Librarylibrary]]