BCA Sem 1 | Unit 3 | Computer Concepts & C Programming
Overview of process.h Header File in C — BKNMU Junagadh
Process Control Functions, Execution Pause (Delay), Program Termination (Exit), Error Checking (system), and Legacy Portability Issues
process.h header file is used for Process Control in C programming. It is a non-standard, legacy header, primarily found in older Borland compilers (like Turbo C), containing declarations for functions required to create, terminate, pause, or query processes running on the host system. It gives the programmer basic command over the program's lifecycle execution flow. This post provides a clear overview for **BKNMU BCA Semester 1 (Unit 3)**.
The process.h library organizes general lifecycle management utilities into four primary categories:
1. Program Exit
Functions that instantly terminate the program. Use 0 for success, non-zero for error, to communicate result back to OS.
2. OS Commands
Used to run external Operating System commands (like `dir` on DOS, `ls` on Linux) directly from inside your C application.
3. Execution Pause
Halts (sleeps) program execution for a specified duration. *Important: Takes parameter in **milliseconds** (legacy Turbo C).*
4. Forceful Stop
Abnormally terminates execution without cleanup (`abort`) or checks logical condition assertions before proceeding (`assert`).
Here is a detailed breakdown of the primary functions supplied by the non-standard process.h library, tailored for older compilers.
| Function Name | Functional Description | Standard Parameters / Coordinate System |
|---|---|---|
void exit(int) | Instantly terminates execution. Performs standard library cleanup (flush buffers, etc.). | Exit Code Integer (0=Success, Non-zero=Error). |
void _exit(int) | Instantly terminates execution. Does NOT perform library cleanup (faster, forceful). | Exit Code Integer. |
int system(const char*) | Executes an Operating System command provided as a text string. | Text String (e.g., "dir", "pause"). Returns command return value. |
void delay(unsigned) | Halts program execution for the specified time period. | Time parameter is strictly in **Milliseconds** (e.g., delay(1000) = 1 sec). |
void abort(void) | Forcefully abnormally terminates program execution. Usually generates a core dump in debugging environments. | Takes no parameters. Returns nothing. |
int assert(expression) | Evaluates a condition. If condition is False, prints error message and calls `abort()`. Used strictly for debugging logic. | Logical Expression (e.g., x > 0). Defined in ` |
1. Using delay(), system(), and exit() in Turbo C:
#include <stdio.h>
#include <process.h> // Required for delay and exit
#include <conio.h> // Required for getch() pause (sometimes required in TC with system)
int main() {
int count = 5;
printf("Program lifecycle demo starting.\n");
while (count > 0) {
printf("Waiting... countdown: %d\n", count);
// 1. Delay execution: 1 second pause (1000 ms)
delay(1000);
count--;
}
printf("\nTime's up! Showing current directory...\n");
// 2. Execute DOS command 'dir' directly
system("dir");
printf("\nProgram finished successfully.\n");
// 3. Communicating success back to OS
exit(0);
return 0; // This line is NEVER executed
}
Step 1: Driver Detection & Initialization
The preprocessor loads declarations.Attribute setupAttribute functions Attributes.
Step 2: OS Call & Interruption
Execution encountering `system()` or `delay()` initiates standard BIOS or OS Interrupt calls (like INT 21H on DOS), suspending current process priority until the lifecycle event is resolved.