Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following program #include csapp.h sigchld_handler (int sig) (void)sig; Write (STDOUT_FILENO, 1, 1); main(void) pid.t pid; int status; Signal (SIGCHLD, sigchld handler); if (fork)0)

image text in transcribed

Consider the following program #include "csapp.h" sigchld_handler (int sig) (void)sig; Write (STDOUT_FILENO, "1", 1); main(void) pid.t pid; int status; Signal (SIGCHLD, sigchld handler); if (fork)0) f -0) Write (STDOUT_FILENO, "3", 1); if (fork() else if ((pid - wait(&status)) > 0) Write the function my_readline ) according to the following specification *Requires: *If *bufp is not NULL, then *bufp must point to a buffer that was * previously allocated by malloc() or realloc() and lenp must be less * than or equal to the size of that buffer. * Effects: *Attempts to read a 'n'-terminated line from the given file descriptor, * fd. Copies this line, including the 'In', into the buffer referenced * by *bufp. If *bufp is NULL or the current size of the buffer, as giver *by *lenp, is too small to store the entire line, then realloc) is * performed on the buffer to enlarge it. The enlarged buffer is returned * by reference using bufp. Similarly, the number of characters stored in * the buffer is returned by reference using lenp Returns 0 upon success. Returns EOF if read) returns an end-of-file * indication before a ' ' is encountered. Nonetheless, the buffer * referenced by *bufp will contain all of the characters successfully * read before that end-of-file indication, and lenp will equal the number of characters in that buffer. Returns the value of errno if * either realloc) returns NULL or read() returns -1. In either case, as Consider the following program #include "csapp.h" sigchld_handler (int sig) (void)sig; Write (STDOUT_FILENO, "1", 1); main(void) pid.t pid; int status; Signal (SIGCHLD, sigchld handler); if (fork)0) f -0) Write (STDOUT_FILENO, "3", 1); if (fork() else if ((pid - wait(&status)) > 0) Write the function my_readline ) according to the following specification *Requires: *If *bufp is not NULL, then *bufp must point to a buffer that was * previously allocated by malloc() or realloc() and lenp must be less * than or equal to the size of that buffer. * Effects: *Attempts to read a 'n'-terminated line from the given file descriptor, * fd. Copies this line, including the 'In', into the buffer referenced * by *bufp. If *bufp is NULL or the current size of the buffer, as giver *by *lenp, is too small to store the entire line, then realloc) is * performed on the buffer to enlarge it. The enlarged buffer is returned * by reference using bufp. Similarly, the number of characters stored in * the buffer is returned by reference using lenp Returns 0 upon success. Returns EOF if read) returns an end-of-file * indication before a ' ' is encountered. Nonetheless, the buffer * referenced by *bufp will contain all of the characters successfully * read before that end-of-file indication, and lenp will equal the number of characters in that buffer. Returns the value of errno if * either realloc) returns NULL or read() returns -1. In either case, as

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

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

apply communication design concepts into creative projects.

Answered: 1 week ago

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago