Question: In the code abort.c we discussed in class, it uses hard-coded bit-manipulation to access the child process termination status. Rewrite this code using the bit-

In the code abort.c we discussed in class, 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.

source code

abort.c
In the code abort.c we discussed in class, it uses hard-coded bit-manipulation
 

#include #include #include #include #include int main() { int newpid; printf("before: mypid is %d ", getpid()); if ((newpid = fork( ) ) == -1 ) perror("fork"); else if (newpid == 0){ printf("I am the child %d now sleeping... ",getpid()); sleep (5); abort(); } else{ printf("I am the parent %d ",getpid()); int status; int child pid = wait(&status); printf ("My child %d has terminated ", child_pid); printf("I have received the status = % ", status); int child_status = status >> 8; int signal = status & 0x7F; int core status & 0x80; printf("Child status = $d Signal = $d Core = %d ", child_status, signal, core); } } #include #include #include #include #include int main() { int newpid; printf("before: mypid is %d ", getpid()); if ((newpid = fork( ) ) == -1 ) perror("fork"); else if (newpid == 0){ printf("I am the child %d now sleeping... ",getpid()); sleep (5); abort(); } else{ printf("I am the parent %d ",getpid()); int status; int child pid = wait(&status); printf ("My child %d has terminated ", child_pid); printf("I have received the status = % ", status); int child_status = status >> 8; int signal = status & 0x7F; int core status & 0x80; printf("Child status = $d Signal = $d Core = %d ", child_status, signal, core); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!