Eishal OS
Eishal OS
UNIVERSITY OF JHANG
Fork() System call program in C Language:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void create_process() {
if (pid < 0) {
exit(1);
else if (pid == 0) {
// Child process
exit(0);
else {
// Parent process
wait(NULL);
int main()
create_process();
return 0;
#include <stdio.h>
#include <stdlib.h>
if (file != NULL) {
fclose(file);
else {
printf("Invalid handle.\n");
int main() {
// Example usage
close_handle(file);
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void exec_process() {
execvp(args[0], args);
printf("Exec failed!\n");
exit(1);
}
int main() {
// Example usage
exec_process();
return 0;
#include <stdio.h>
#include <stdlib.h>
void exit_process()
exit(0);
int main() {
// Example usage
exit_process();
return 0;
THE END