job-control

How do I make a background process block for input a la the shell's `bg` command?

烂漫一生 提交于 2021-01-28 08:15:23
问题 I am implementing my own fragment of code for a security control purpose. It normally runs in the background but on a timeout needs to take over the current terminal, display a message, collect user input, and react to the user input. Waiting for the timeout is easy. Collecting user input while sleep is the active program is easy. Preventing the shell from stealing the user input I just tried to collect is not so easy. I am reasonably convinced that "What if two programs did this?" doesn't

How to tell bash not to issue warnings “cannot set terminal process group” and “no job control in this shell” when it can't assert job control?

情到浓时终转凉″ 提交于 2021-01-27 18:23:12
问题 To create a new interactive bash shell I call bash -i . Due to issues with my environment, bash cannot assert job control (I'm using cygwin bash in GNU emacs) and issues warnings ("cannot set terminal process group" and "no job control in this shell"). - I have to live with the disabled job control in my environment, but I would like to get rid of the warning: How can I tell bash not to assert job control and not to issue these warnings? I obviously still want the shell as an interactive one.

Wait for bash background jobs in script to be finished

余生长醉 提交于 2019-12-28 05:30:47
问题 To maximize CPU usage (I run things on a Debian Lenny in EC2) I have a simple script to launch jobs in parallel: #!/bin/bash for i in apache-200901*.log; do echo "Processing $i ..."; do_something_important; done & for i in apache-200902*.log; do echo "Processing $i ..."; do_something_important; done & for i in apache-200903*.log; do echo "Processing $i ..."; do_something_important; done & for i in apache-200904*.log; do echo "Processing $i ..."; do_something_important; done & ... I'm quite

Job control in linux with C

£可爱£侵袭症+ 提交于 2019-12-23 12:20:10
问题 What I know: When a process is running I can press "CTRL + Z" and suspend it. The with bg and fg commands I can either run it in "background" or "foreground" mode. What I'm aksing: Is there a way to suspend a process, send it to run in background or foreground in C? Edit: I have the process id. I want to send that process to the background for example. 回答1: You can suspend it with kill(pid, SIGSTOP), but making it foreground or background is a function of the shell that ran it, since what it

How to switch terminal to new child process of process launched with NSTask?

☆樱花仙子☆ 提交于 2019-12-23 03:37:32
问题 I made a pseudo terminal with method described here: http://lists.apple.com/archives/student-dev/2005/Mar/msg00019.html The terminal itself worked well. Anyway the problem is terminal cannot being switched to child process. For an example, I launched bash with NSTask , and if I execute ftp within the bash , it stops automatically. ftp ftp ftp> [1]+ Stopped ftp bash-3.2$ And if I try to continue the ftp with fg , it terminates quietly. (I checked this with Activity Monitor ) fg fg ftp bash-3.2

In what order should I send signals to gracefully shutdown processes?

我怕爱的太早我们不能终老 提交于 2019-12-17 03:46:38
问题 In a comment on this answer of another question, the commenter says: don’t use kill -9 unless absolutely necessary! SIGKILL can’t be trapped so the killed program can’t run any shutdown routines to e.g. erase temporary files. First try HUP (1), then INT (2), then QUIT (3) I agree in principle about SIGKILL , but the rest is news to me. Given that the default signal sent by kill is SIGTERM , I would expect it is the most-commonly expected signal for graceful shutdown of an arbitrary process.

How to switch terminal to new child process of process launched with NSTask?

别来无恙 提交于 2019-12-07 09:53:55
I made a pseudo terminal with method described here: http://lists.apple.com/archives/student-dev/2005/Mar/msg00019.html The terminal itself worked well. Anyway the problem is terminal cannot being switched to child process. For an example, I launched bash with NSTask , and if I execute ftp within the bash , it stops automatically. ftp ftp ftp> [1]+ Stopped ftp bash-3.2$ And if I try to continue the ftp with fg , it terminates quietly. (I checked this with Activity Monitor ) fg fg ftp bash-3.2$ fg fg bash: fg: current: no such job bash-3.2$ I think it needs some more infrastructure (which

Does linux kill background processes if we close the terminal from which it has started?

二次信任 提交于 2019-12-03 02:01:56
问题 I have an embedded system, on which I do telnet and then I run an application in background: ./app_name & Now if I close my terminal and do telnet from other terminal and if I check then I can see this process is still running. To check this I have written a small program: #include<stdio.h> main() { while(1); } I ran this program in my local linux pc in background and I closed the terminal. Now, when I checked for this process from other terminal then I found that this process was also killed

Does linux kill background processes if we close the terminal from which it has started?

无人久伴 提交于 2019-12-02 15:38:40
I have an embedded system, on which I do telnet and then I run an application in background: ./app_name & Now if I close my terminal and do telnet from other terminal and if I check then I can see this process is still running. To check this I have written a small program: #include<stdio.h> main() { while(1); } I ran this program in my local linux pc in background and I closed the terminal. Now, when I checked for this process from other terminal then I found that this process was also killed. My question is: Why undefined behavior for same type of process? On which it is dependent? Is it

bg / fg inside a command line loop

冷暖自知 提交于 2019-11-29 07:12:49
ctrl-z (^z) acts in ways I do not understand when done inside a loop executed from a terminal. Say I type for ii in {0..100}; do echo $ii; sleep 1; done then I hit ^z. I'll get: [1]+ Stopped sleep 1 I can resume the job using fg or bg, but the job refers only to he sleep command. The rest of the loop has apparently disappeared, and no more number appear on the terminal. I could use & after the command to immediately run it in the background, or another solution is to wrap the whole thing in a subshell: ( for ii in {0..100}; do echo $ii; sleep 1; done ) then ^z gives me [1]+ Stopped ( for ii in