1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anestetic [448]
3 years ago
9

Before your shell forks a new process to call execvp(), it should parse the input string and separate it into a collection of su

bstrings representing the executable file and any command-line arguments. If the user entered an empty line, report an error and fetch a new line of input. Your code must handle at least four command-line arguments (in addition to the name of the executable file itself).
Computers and Technology
1 answer:
kompoz [17]3 years ago
3 0

Answer:

#define LSH_RL_BUFSIZE 1024

char *lsh_read_line(void)

{

int bufsize = LSH_RL_BUFSIZE;

int position = 0;

char buffer = malloc(sizeof(char) bufsize);

int c;

if (!buffer) {

   fprintf(stderr, "lsh: allocation error\n");

   exit(EXIT_FAILURE);

}

while (1) {

   // Read a character

   c = getchar();

   // If we hit EOF, replace it with a null character and return.

   if (c == EOF || c == '\n') {

     buffer[position] = '\0';

     return buffer;

   } else {

     buffer[position] = c;

   }

   position++;

   // If we have exceeded the buffer, reallocate.

   if (position >= bufsize) {

     bufsize += LSH_RL_BUFSIZE;

     buffer = realloc(buffer, bufsize);

     if (!buffer) {

       fprintf(stderr, "lsh: allocation error\n");

       exit(EXIT_FAILURE);

     }

   }

}

}

Explanation:

You might be interested in
Explain the two filter options available when filtering by a column
dexar [7]
Can you prove more information?
8 0
3 years ago
Read 2 more answers
Types of email resources. Examples
denis23 [38]
Newsletter emails
Milestone emails
Welcome emails
Review request emails

Hope this helps!
8 0
3 years ago
Direct messages are the only private forms of communication on Twitter. True False
Sunny_sXe [5.5K]
True but ill keep typing so it meets twenty charecters                                              

7 0
3 years ago
What is composition
Dmitry [639]
The term composition in simple words is “putting together”. It is a thing composed of various elements.
4 0
3 years ago
What is an unintended consequence of pesticides used on crops
RUDIKE [14]
<span>They leave a residue on the surface or inside the crop treated. </span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • Into which of these files would you paste copied information to create an integrated document? A. Mailing list B. Source C. Data
    13·2 answers
  • A cast is required in which of the following situations? a. using charAt to take an element of a String and store it in a char b
    7·1 answer
  • Select the proper ergonomic keyboarding techniques.
    9·1 answer
  • Which of the following is generally nota desire today's workers? A. computer ability B willingness to learn C. teamwork skills D
    8·1 answer
  • Which of the following is most likely to be a result of hacking? Group of answer choices slowing of network speed certain Web si
    13·1 answer
  • Components that enhance the computing experience, such as computer keyboards, speakers, and webcams, are known as
    7·1 answer
  • Choose the correct term to complete the sentence.
    12·1 answer
  • What do you mean by HDML coding ​
    13·1 answer
  • Describe the data update difference between operational and analytical data.
    15·1 answer
  • T/F static development is the process of constructing the programs and code modules that serve as the building blocks of the inf
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!