Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete both tasks for a thumbs up :-) #include #include int main (void) { printf(I am process %ld , (long) getpid()); printf(My parent is

Please complete both tasks for a thumbs up :-)

image text in transcribed

#include  #include  int main (void) { printf("I am process %ld ", (long) getpid()); printf("My parent is %ld ", (long)getppid()); printf("Process user id is %ld ", (long)getuid()); printf("Group id is %ld ", (long)getgid()); return 0; } 

image text in transcribed

#include  #include"stdio.h" #include  int globalVariable = 2; int main() { char parentStr[] = "Parent Process"; char childStr[] = "Child Process"; char *string = NULL; int functionVariable = 20; // Create a child process. pid_t pid = ______; if (______) // Failed to fork { perror("Unable to create child process"); return 1; } else if (______) // child { // Code only executed by child process string = &childStr[0]; globalVariable++; functionVariable++; } ______ // parent { // Code only executed by parent process string = &parentStr[0]; globalVariable += 2; functionVariable += 2; } // Code executed by both parent and child. printf("%s ", string); printf(" Global Variable: %d ",globalVariable); printf(" Function Variable: %d ", functionVariable); } 
Task 1' (20 points) Here is a C program that prints out the process id, the parent process id, the process user id, and group id. Please type it in your computer and save as taskl.c. Now compile it and run it to see how it works Include your screenshots in your submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions