1
vote
1answer
22 views

PID of process causing error

I have this script: #!/bin/bash # -> dump.$pid ulimit -c unlimited # trap ERR set -o errexit # also trap error in the middle of a pipe (1) # otherwise it will only trap the error on (2) set -o ...
3
votes
2answers
50 views

Why is my trap not printing any log message?

What I'm doing is, trap 'rm -f /path/of/file/fileName.running; echo "TRAPPED & READY";' 1 2 9 15 >> trap.log I didn't get anything in log & the file which should have been deleted ...
2
votes
1answer
68 views

Forward SIGTERM to child in Bash

I have a Bash script, which looks similar to this: #!/bin/bash echo "Doing some initial work...."; /bin/start/main/server --nodaemon Now if the bash shell running the script receives a SIGTERM ...
5
votes
1answer
40 views

Ctrl-C is ignored by pppd when put in a shell script

I'm trying to connect to GPRS network through a serial port connected GSM modem. When I call /usr/sbin/pppd call <peer_name> from the command line, it correctly receives and handles Ctrl+C from ...
2
votes
1answer
381 views

ctrl c vs. ctrl z with foreground job

Ctrl+Z stops the job whereas Ctrl+C kills the job. Why is that? Wouldn't the other way make more sense? z@z-lap:~$ sleep 100& [1] 4458 z@z-lap:~$ sleep 200& [2] 4459 z@z-lap:~$ jobs [1]- ...
2
votes
3answers
107 views

CTRL C behavior in hierarchy of shells

First of all sorry about terminology errors, I'd try to be clear. I open a shell (like sbt or node debug from my bash). Then inside this shell, I open another one (using scala or node repl ...
3
votes
5answers
693 views

Getting pid of bash script from itself

I have a bash script with doing lot of things called script.sh: #!/bin/bash #It #Is #Doing #Things Is there a way that I be able to get the proccess of script and then kill it after 5 minutes? ...
0
votes
2answers
262 views

Disable the display of “terminated xxx” info of bash

For example, when I kill a background process, then bash weil display terminated xxx, How to disable this info? $ ping g.cn >/dev/null & [1] 25123 $ pkill ping [1] + 25123 terminated ping ...
2
votes
1answer
51 views

calling sigprocmask from bash

I have a process that spawn a bash command with system() while the signal mask has all the signals blocked. This cannot be fixed easily. The bash command eventually execs into a process. The all ...
2
votes
2answers
128 views

Bash script to signal a concurrently running instance (same script) about a condition and increment counter

Background Here's what I want to achieve. I have a (potentially) long-running process. Now I have locking in place just fine and all is generally in order. However, since this is a scheduled job, ...
1
vote
1answer
144 views

service killed at ssh hangup [duplicate]

If I use ssh to run some command in background, that command gets killed as soon an ssh hangs up: ssh localhost -t "bash -c '(for i in 1 2 3 4 5; do sleep \$i;done)&'"; ps x|grep sleep This ...
4
votes
4answers
2k views

Ctrl-C with two simultaneous commands in bash

I want to run two commands simultaneously in bash on a Linux machine. Therefore in my ./execute.sh bash script I put: command 1 & command 2 echo "done" However when I want to stop the bash ...
2
votes
1answer
291 views

Suppress “Alarm clock: 14” from ping

I've made a simple script for rebooting my router and afterwards showing a progress bar until my computer has an internet connection again. When running the script I get the following output: The ...
4
votes
3answers
230 views

What process is running before I even get a prompt?

When I log in to a specific server I see the following: Note that I get get Last login: ... information but no prompt. I hit Ctrl+C and only then do I get my prompt, thus proving that my username ...
4
votes
1answer
553 views

A script's background process is still alive after closing the terminal

This is more of a process management/signal handling question than a Bash question. It just uses Bash to explain the issue. I'm running a Bash script in which I run a background process. This is the ...
6
votes
3answers
2k views

What's the difference between Ctrl-Z and kill -STOP?

When I run a command (make on a large project) from the shell, I can type Ctrl-Z to stop the process and return to the shell. Subsequently, I can run fg to continue the process. I'm trying to write a ...
2
votes
1answer
101 views

Chain commands with Control + C interrupt

I am trying to execute a program which loops indefinitely, and so must be forcibly interrupted. After executing the program, I want to delete it. I can do it in several steps: ./MyProg Control + C ...
8
votes
2answers
2k views

“trap … INT TERM EXIT” really necessary?

Many examples for trap use trap ... INT TERM EXIT for cleanup tasks. But is it really necessary to list all the three sigspecs? The manual says: If a SIGNAL_SPEC is EXIT (0) ARG is executed on ...
2
votes
2answers
737 views

Why can't I kill a timeout called from a Bash script with a keystroke?

[Edit: This looks similar to some other questions asking how to kill all spawned processes – the answers all seem to be to use pkill. So the core of my question may be: Is there a way to propagate ...
1
vote
0answers
254 views

Why does this pipeline get SIGTTIN?

When I run the command for i in *.log; do cat "$i" | sort; done | more, the pipeline gets a SIGTTIN signal and is stopped. bash$ for i in *.log; do cat "$i" | sort; done | more ### (one screenful of ...
9
votes
4answers
4k views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I Ctrlc the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
10
votes
5answers
15k views

How to stop the loop bash script in terminal?

For example, #!/bin/bash while : do sl done How to terminate this bash script?
9
votes
6answers
6k views

Terminating an infinite loop

I have a command that I want to have run again automatically each time it terminates, so I ran something like this: while [ 1 ]; do COMMAND; done; but if I can't stop the loop with Ctrl-c as that ...
3
votes
1answer
890 views

Issue with WINCH signal - what am I overlooking?

I am having an issue with the WINCH signal in the following code which is from a tutorial located at developerWorks®: #!/bin/bash trap 'get_window_size' WINCH # trap when a user ...
3
votes
2answers
4k views

How can I trap a program that returns 139 (segmentation fault) in bash?

I have a bash script that tests some programs and one of the program returns Segmentation fault so I tried to add a trap in the head of my script: trap "echo 'segfault occured!'" SIGSEGV That ...
3
votes
2answers
696 views

Wrapper program that sets signal handler

I would like to have a wrapper program that runs a given command and sets a signal handler so that it gets run when the command receives a specified signal. The question is this: Is there an ...
3
votes
1answer
3k views

What is signal 0 in a trap command?

I'm following this guide on how to set up passwordless SSH authentication with ssh-agent. To start up ssh-agent the author recommends the following code in .bash_profile: SSHAGENT=/usr/bin/ssh-agent ...
1
vote
1answer
2k views

Can you specify a separate trap in a subshell created with ()?

I'm writing a script that starts a subshell to go off and do some work. In a special case, the script needs to tell the subshell to cleanly stop what it's doing and exit early. However, my ...