Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help Me! Help is greatly appreciated! I am not getting the output I am supposed to be getting for this function, below is all

Please help Me! Help is greatly appreciated!

I am not getting the output I am supposed to be getting for this function, below is all the necessary information (code is in C language).

Here is my code:

image text in transcribed

image text in transcribed

Here is the details of this function:

image text in transcribed

Must use fork, exec, wait.

void print kernel_release() [ pid_t process int tracker; process fork( tracker 0; if(process-0) fprintf(stdout, "Failed to fork a process n" perror("fork()"); exit(1) else if(process0) char * kernel-args[] {"uname " , "-a",NULL); execv("/bin/unane",kernel_args); waitpid (process, &tracker, 0); if(tracker-0) fprintf(stdout, "Failed to wait for process to complete.") perror("waitpid)") exit(1); else fprintf(stdout, "Success!n"; Question #1 : Implementing print-kernel-release) [20 pts] When the user types 1', the print_kernel_release() function prints the kernel version as follows 1. See the kernel release 2. See the number of cores 3. See the RAM capacity 4. Exit I user types '1' 4.4.0-103-generic The output above is simply the output of the uname command with particular command-line arguments (read the man page to find out which ones). Rather than re-implementing uname to generate this output (which would be painful), implement print_kernel_release()by Starting a child process Having that child process exec the uname program with the right arguments Wait for the child process to complete Here are a few hints There is a whole family of exec system calls (do a man exec and really read the man page). You can use whichever exec you want, but some are more convenient than others. Note that in your real Linux Shell, you can find out the path to any command by typing which and then the command. For instance, "which 1s" will tell you where the 1s executable is stored on the file system. Providing full path to exec is typically necessary

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

Transactions On Large Scale Data And Knowledge Centered Systems Vi Special Issue On Database And Expert Systems Applications Lncs 7600

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2012th Edition

3642341780, 978-3642341786

More Books

Students also viewed these Databases questions