Professional Documents
Culture Documents
CH 2
CH 2
Process Management
2.1 - Processes and Threads
By Kindu T.
• One-to-One
• Many-to-Many
2. Terminating Processes:
exit(): This function is used to terminate the calling process and
return an exit status to the operating system.
Example:
Process control using C…
3. Process Identification:
getpid(): This function returns the process ID (PID) of the calling process.
getppid(): This function returns the parent process ID (PPID) of the calling
process. Example:
Process control using C…
Example:
1. Opening Files:
• Opens "source.txt" for reading and "destination.txt" for writing.
2. Copying Contents:
• Reads data from "source.txt" and writes it to "destination.txt" until the end of file is reached.
3. Closing Files:
• Closes both file descriptors.
Remember to handle errors properly, especially when dealing with file operations.
The perror() function is used to print descriptive error messages to stderr in case of
file manipulation errors.
File manipulation using C…
Example:
Thank
You!!!