Question 1:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
pid_t pid;
if ((pid = fork()) == 0) {
while (1) {
printf(“child’s return value %d: I want to play…\n”, pid);
} else {
while (1) {
printf(“parent’s return value %d: After the project…\n”, pid);
return 0;
Question 2:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#define LB_SIZE 1024
int main(int argc, char *argv[]) {
char fullPathName[] = “/usr/X11R6/bin/xeyes”;
char *myArgv[LB_SIZE]; // an array of pointers
myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
strcpy(myArgv[0], fullPathName);
myArgv[1] = NULL; // last element should be a NULL pointer
execvp(fullPathName, myArgv);
exit(0); // should not be reached
}
Terminal Mai aa k us directory Mai ja k
gcc (filename).c
Phir
./a.out
&&&
sudo yum install gcc-c++
&&&
GCC install krne k liye
&&&
sudo yum -y install xorg-x11-apps
&&&
Q1:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
pid_t pid;
if ((pid = fork()) == 0) {
while (1) {
printf("child’s return value %d: I want to play...\n", pid);
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>
#define LB_SIZE 1024
int main(int argc, char *argv[]) {
char fullPathName[] = "/usr/bin/xeyes";
char *myArgv[LB_SIZE];
// an array of pointers
myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
strcpy(myArgv[0], fullPathName);
myArgv[1] = NULL; // last element should be a NULL pointer
execvp(fullPathName, myArgv);
exit(0);
// should not be reached
&&&
install k baad xeyes &