subject
Engineering, 08.05.2021 03:30 talannajanis

Unix shells support the notion of job control, which allows users to move jobs back and forth between background and foreground, and to change the process state (running, stopped, or terminated) of the processes in a job. Typing ctrl-c causes a SIGINT signal to be delivered to each process in the foreground job. The default action for SIGINT is to terminate each process. Similarly, typing ctrl-z causes a SIGTSTP signal to be delivered to each process in the foreground job. The default action for SIGTSTP is to place a process in the stopped state, where it remains until it is awakened by the receipt of a SIGCONT signal. Unix shells also provide various built-in commands that support job control. For example: jobs: List the running and stopped background jobs.
bg : Change a stopped background job to a running background job.
fg : Change a stopped or running background job to a running in the foreground.
kill : Terminate a job.
Implement these commands in your smallsh. c program. You have to use your own signal handler routines for these purposes along with a simple data structure for maintaining the jobs and processes in each job. You may use process group concept in this implementation for maintaining processes in each job (job may be interpreted as a process group). If your program use fork() system calls, multiple children processes will be created which belong to the same job as your original process which spawned the children processes.
Example
Suppose that you have a program that includes 1 fork system call. Let’s name that executable file as "prog1". Also, assume that both the parent and the child process will sleep 60 seconds and exit. Suppose that you execute the following sequence of commands in less than 60 seconds.

Command> prog1&

Command> prog1&

Command> prog1

…

Then there are 3 jobs created where each job contains 2 processes. One job is running in foreground, and two jobs are running in background.



#include "smallsh. h"
int runcommand(Char **cline, int where)
{
pid_t pid;
int status;

switch(pid=fork())
{
case -1:
perror("smallsh");
return(-1);
case 0:
execvp(*cline, cline);
perror(*cline)
exit(1);
}
if(where==BACKGROUND)
{
printf("process id is %d\n",pid);
return 0;
}
if(waitpid(pid,&status,0)==-1)< br /> return -1;
else
return status;
}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Abrake has a normal braking torque of 2.8 kip in and heat-dissipating cast-iron surfaces whose mass is 40 lbm. suppose a load is brought to rest in 8.0 s from an initial angular speed of 1600 rev/min using the normal braking torque; estimate the temperature rise of the heat dissipating surfaces.
Answers: 3
question
Engineering, 04.07.2019 18:10
Ariver flows from north to south at 8 km/h. a boat is to cross this river from west to east at a speed of 20 km/h (speed of the boat with respect to the earth/ground). at what angle (in degrees) must the boat be pointed upstream such that it will proceed directly across the river (hint: find the speed of the boat with respect to water/river)? a 288 b. 21.8 c. 326 d. 30.2
Answers: 3
question
Engineering, 04.07.2019 18:10
Consider a large isothermal enclosure that is maintained at a uniform temperature of 2000 k. calculate the emissive power of the radiation that emerges from a small aperture on the enclosure surface. what is the wavelength ? , below which 10% of the emission is concentrated? what is the wavelength ? 2 above which 10% of the emission is concentrated? determine the wavelength at which maximum spectral emissive power occurs. what is the irradiation incident on a small object placed inside the enclosure?
Answers: 2
question
Engineering, 04.07.2019 18:10
What are the two (02) benefits, which may result from a successful implementation of preventive maintenance (pm) program in an organization? (clo3)a)- lean manufacturing b)-overlapping responsibilities c)-the planner is not qualified d)-accurate contractor information e)-reduction in equipment redundancies f)-accurate stores information
Answers: 3
You know the right answer?
Unix shells support the notion of job control, which allows users to move jobs back and forth betwee...
Questions
question
History, 07.05.2021 19:00
question
Mathematics, 07.05.2021 19:00
question
Mathematics, 07.05.2021 19:00
question
Mathematics, 07.05.2021 19:00
Questions on the website: 13722360