Question 1 In the code "abort.c" (posted under Process Control), it uses hard-coded bit-manipulation to access the child process termination status. Rewrite this code using the bit-manipulation macros discussed in the lecture. Submit the source code and script files.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question
Like will be given instantly urgently please
Question 1
In the code "abort.c" (posted under Process Control), it uses hard-coded
bit-manipulation to access the child process termination status. Rewrite this
code using the bit-manipulation macros discussed in the lecture. Submit the
source code and script files.
PLEASE COMPLETE IN C
abort.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
int newpid;
printf("before: mypid is %d\n", getpid();
if ((newpid = fork() == -1)
perror("fork");
else if (newpid == 0}{
printf("l am the child %d now sleeping...\n",getpid()3;
sleep(5);
abort();
else(
printf("l am the parent %d\n",getpid();
int status;
int child_pid = wait(&status);
printf("My child %d has terminated\n",child_pid);
printf("l have received the status = %\n",status);
int child_status = status >> 8;
int signal = status & OX7F;
int core = status & Ox80;
printf("Child status = %d Signal = %d Core = %d\n",
child_status, signal, core);
Transcribed Image Text:Question 1 In the code "abort.c" (posted under Process Control), it uses hard-coded bit-manipulation to access the child process termination status. Rewrite this code using the bit-manipulation macros discussed in the lecture. Submit the source code and script files. PLEASE COMPLETE IN C abort.c #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> int main() { int newpid; printf("before: mypid is %d\n", getpid(); if ((newpid = fork() == -1) perror("fork"); else if (newpid == 0}{ printf("l am the child %d now sleeping...\n",getpid()3; sleep(5); abort(); else( printf("l am the parent %d\n",getpid(); int status; int child_pid = wait(&status); printf("My child %d has terminated\n",child_pid); printf("l have received the status = %\n",status); int child_status = status >> 8; int signal = status & OX7F; int core = status & Ox80; printf("Child status = %d Signal = %d Core = %d\n", child_status, signal, core);
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Analysis of Performance Measurement
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage