Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using your UNIX/LINUX C compiler run the following program with these 3 different options: a) Displaying the output on the screen. b) Directing the output

Using your UNIX/LINUX C compiler run the following program with these 3 different options:

a) Displaying the output on the screen.

b) Directing the output to a file (using ">").

c) Append the output (using ">>") to another file few times.

How many times does the program display "I'm Alive!" for each of the above three cases?

Comment the fflush(stdout) statements out and run the program again. Explain your answer.

Run the program on your machine and on other Linux machines you have access to and compare your findings.

Depending on your compiler you may have to include other header files.

#include

#include

main ()

{

int k;

printf ("Main Process' PID = %d ", getpid());

fflush(stdout);

for (k = 1; k <= 3; k++)

{

fork ();

printf ("k = %d, PPID = %d, pID = %d, I'm Alive! ", k, getppid(), getpid());

fflush(stdout);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions