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
What do you understand by storage devices ? Name any two storage devices.​
MatroZZZ [7]

Answer:

Types of storage devices

Primary Storage: Random Access Memory (RAM) Random Access Memory, or RAM, is the primary storage of a computer. ...

Secondary Storage: Hard Disk Drives (HDD) & Solid-State Drives (SSD) ...

Hard Disk Drives (HDD) ...

Solid-State Drives (SSD) ...

External HDDs and SSDs. ...

Flash memory devices. ...

Optical Storage Devices. ...

Floppy Disks.

6 0
3 years ago
Read 2 more answers
Four workers take an extra half-hour for lunch, at a cost of $14/ hour
Usimov [2.4K]

Answer:

whats the rest ?

Explanation:

whats the rest ?

8 0
3 years ago
Which of these is one of the primary concerns for protecting your family when online?
Lady_Fox [76]
Sharing personal information
7 0
3 years ago
Read 2 more answers
C++ Question: what is in the blanks?
Igoryamba

You didn't specify what the program should output, so there are many possibilities that result in a working program. It *looks* like this was intended:

int x = 24;

int y;

y = x-12;

cout<<y<<endl;

and it will display 12.

8 0
3 years ago
In 1940, the FCC reserved a set of frequencies in the lower range of the FM radio spectrum for _____ purposes as part of its reg
Monica [59]

Answer:

education purposes

Explanation:

Education institutes make some programs like School of the Air and College of the Air, forums, and discussion tables, in 1940 the FCC reserved a range of the FM radio spectrum for education purposes.

Although FM was unpopular when the FCC moved the FM bandwidth to a higher set of frequencies, and people and consumer stations had to buy new equipment.

5 0
3 years ago
Other questions:
  • What can a folder on a computer contain?
    13·2 answers
  • Designing, producing, exhibiting, performing, writing, and publishing multimedia content including visual and performing arts an
    6·1 answer
  • In the single-site processing, single-site data (SPSD) scenario, all processing must be done on the end user's side of the syste
    10·2 answers
  • Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar
    5·1 answer
  • How many questions have you seen so far other than this one?
    10·2 answers
  • If we assume the modern view of existential import, why is the following syllogism invalid? No computer is made of clay. All com
    15·1 answer
  • You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you re
    8·1 answer
  • Which feature of REPL.it would you use to transmit your program to a friend?
    12·1 answer
  • What steps can you take to secure your private information?.
    8·1 answer
  • Zohan uses the following analogy to describe a concept of object-oriented programming. A button can have many uses. When it is p
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!