Question

In: Computer Science

how to send background process to foreground process using c code?

how to send background process to foreground process using c code?

Solutions

Expert Solution

To send a process or to run a process in a system whther in foreground or in background there is a function named as tcsetpgrp which is used for both the purpose. It's just there parameters change according to the requirements. The command for running any process in foreground is -

tcsetpgrp (shell_terminal, j->pgid) ;

The code in c for sending a background process j to foreground is -

void

put_jobforeground (job *j, int conti)

{tcsetpgrp (shell_terminal, j->pgid); ##put the job in foreground.

wait_for_job (j); #wait for the job to report.

tcsetpgrp (shell_terminal, shell_pgid); #put the shell back in Foreground if sent to background.

tcgetattr (shell_terminal, &j->tmodes); #restore the nodes.

tcsetattr (shell_terminal, TCSADRAIN, &shell_tmodes);

}

By this code you can easily run any process in the foreground or can send the process to foreground if it's in the backgroud.


Related Solutions

You and a friend are using the C(7,4) Hamming code to send some 4-bit messages to...
You and a friend are using the C(7,4) Hamming code to send some 4-bit messages to each other. (a) You encode the message 1010 and send the encoded 7-bit sequence to your friend, who receives 1011011. How many errors were introduced during transmission? (b) You subsequently receive the encoded sequence 0111011 from your friend. Assuming at most one error, what is the 4-bit message that your friend sent?
The Case of the Coding Dilemma Background: Coding is the process of assigning a billing code...
The Case of the Coding Dilemma Background: Coding is the process of assigning a billing code to a patient diagnosis. The billing code comes from a standardized code book. Each code represents a specific diagnosis and a designated amount of reimbursement by government and private insurers. Entering a higher code than is warranted will result in overpayment for the patient’s particular diagnosis. Entering a lower code than is warranted will result in underpayment for the patient’s particular diagnosis. All diagnoses...
IN C# WITH SCREENSHOTS OF THE CODE RECURSION Objectives • Learn the basics of recursion. Background...
IN C# WITH SCREENSHOTS OF THE CODE RECURSION Objectives • Learn the basics of recursion. Background There are many problems that loops simplify, such as displaying every pixel to a screen or receiving repetitive input. However, some situations that can be simplified with looping are not easily solvable using loops. This includes problems that require back tracking and being able to use information from previous iterations, which would normally be lost when using an iterative loop. In those cases, it...
C++ Code! This code was written/implemented using the "class format." How would I go about in...
C++ Code! This code was written/implemented using the "class format." How would I go about in converting it to the "struct format?" #include <iostream> #include <iomanip> using namespace std; class ListNode{ public: string course_name; string course_number; string course_room; ListNode* next; ListNode(){ this->next = NULL; } ListNode(string name, string number, string room){ this->course_name = name; this->course_number = number; this->course_room = room; this->next = NULL; } }; class List{ public: ListNode* head; List(){ this->head = NULL; } void insert(ListNode* Node){ if(head==NULL){ head...
C++ (data structure using c++). please send me copyable file. Write a program and test a...
C++ (data structure using c++). please send me copyable file. Write a program and test a program that translates the following Bubble Sort algorithm to a bubblesort function. The function's prototype is, void bubblesort(int a[], int size); Bubble Sort The inner loop moves the largest element in the unsorted part of the array to the last position of the unsorted part of the array; the outer loop moves the last position of the unsorted part of the array. The Bubble...
write code to manage a linked list using recursive approach. (Using this code) C++ IN Unix....
write code to manage a linked list using recursive approach. (Using this code) C++ IN Unix. // app.cpp #include <iostream> #include "linkedlist.h" using namespace std; void find(LinkedList& list, char ch) {    if (list.find(ch))        cout << "found ";    else        cout << "did not find ";    cout << ch << endl; } int main() {    LinkedList   list;    list.add('x');    list.add('y');    list.add('z');    cout << list;    find(list, 'y');    list.del('y');    cout...
How do i send random numbers in my Amazon SES email? What is the code for...
How do i send random numbers in my Amazon SES email? What is the code for it and where would it go Lambda or SES? Please provide step by step instructions
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an...
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an earthquake is in the range [0, 3), “medium” if M is in the range [3, 6), “large” if M is in the range [6, 9) and “epic” if M is greater than or equal to 9, where M is input by a user via the keyboard. (in c++)
code in c++ using the code given add a hexadecimal to binary converter and add a...
code in c++ using the code given add a hexadecimal to binary converter and add a binary to hexadecimal converter #include <iostream> #include <string> #include<cmath> #include<string> using namespace std; int main() { string again; do { int userChoice; cout << "Press 2 for Decimal to Binary"<< endl; cout << "Press 1 for Binary to Decimal: "; cin >> userChoice; if (userChoice == 1) { long n; cout << "enter binary number" << endl; cin>>n; int decnum=0, i=0, remainder; while(n!=0) {...
How many times should the following C code print "Example" and draw a process graph #include...
How many times should the following C code print "Example" and draw a process graph #include <stdio.h> #include <sys/types.h> #include <unistd.h> void try() { fork(); printf("Example\n"); fork(); return; } int main() { try(); fork(); printf("Example\n"); exit(0); }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT