OS - Assignment 1
OS - Assignment 1
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
pid_t pid;
if ((pid = fork()) == 0) {
while (1) {
} else {
while (1) {
return 0;
Question 2:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
strcpy(myArgv[0], fullPathName);
myArgv[1] = NULL; // last element should be a NULL pointer
execvp(fullPathName, myArgv);
}
Terminal Mai aa k us directory Mai ja k
gcc (filename).c
Phir
./a.out
&&&
&&&
&&&
&&&
Q1:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
pid_t pid;
if ((pid = fork()) == 0) {
while (1) {
else {
while (1) { printf("parent’s return value %d: After the project...\n", pid);
return 0;
&&&
Q2:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include<string.h>
#include<stdlib.h>
char *myArgv[LB_SIZE];
// an array of pointers
strcpy(myArgv[0], fullPathName);
execvp(fullPathName, myArgv);
exit(0);
&&&