I have in  a script  trap 'kill ${!}; term_handler' SIGTERM   So the SIGTERM is executed when we kill the pid ${!}
86903
If I'm assigning a variable with  temp=$!   what would it be its value?
95532
If I have the script "script1.sh" and I want to make it print its own PID as a first step. How can I do this in bash?
83138
If I issue the trap builtin twice [for the same signal], what happens? Is the second command added to the first, or does it replace the first?  trap Foo SIGINT ... trap Bar SIGINT ...   When SIGINT happens, does Bash just run Bar, or does it run Foo as well? Or something else...?
1123
What is the primary difference between the two? I always see this in the right click menu in windows. What happens if you end a process that is relied upon by another process? Is there a way to "kill" a process tree in linux or is the technology different?
17920
I am looking for a simple and generic solution that would allow you to execute any script or application in crontab and prevent it from running twice.  The solution should be independent on the executed command.  I assume it should look like lock &amp;&amp; (command ; unlock) where lock will return false if there was another lock.  The second part would be like if it acquired the lock, run command and unlock after command is executed, even if it returns error.
87730
I have a small shell script called "k" that i call everytime when i want to reset my complete Development Cycle:  killall node killall Xcode killall Terminal   How can i find out the final name of the "Visual Studio Code"-Prozess to kill it also this way?  I've tried:  killall "Visual Studio Code"      No matching processes belonging to you were found   killall "Code"      No matching processes belonging to you were found   Any ideas? I am looking for a generic approach without any manually lookup of PIDs necessary.  This application looks like this in Activity Monitor:
2490
I have a process I can't kill with kill -9 &lt;pid&gt;. What's the problem in such a case, especially since I am the owner of that process. I thought nothing could evade that kill option.
63049
I found malware on my ec2 instance which was continuously mining bitcoin and using my instance processing power. I successfully identified the process, but was unable to remove and kill it.  I ran this command  watch "ps aux | sort -nrk 3,3 | head -n 5"  It shows the top five process running on my instance, from which I found there is a process name 'bashd' which was consuming 30% of cpu.  The process is   bashd -a cryptonight -o stratum+tcp://get.bi-chi.com:3333 -u 47EAoaBc5TWDZKVaAYvQ7Y4ZfoJMFathAR882gabJ43wHEfxEp81vfJ3J3j6FQGJxJNQTAwvmJYS2Ei8dbkKcwfPFst8FhG -p x   I killed this process by using the kill -9 process_id command. After 5 seconds, the process started again.
57505
This is the command ps -A |grep -i apache2 output:  xxxx@debian:~$ ps -A |grep -i apache2  2362 ?        00:00:01 apache2  2365 ?        00:00:00 apache2  2367 ?        00:00:00 apache2  2369 ?        00:00:00 apache2   Which is the correct pid when i use killcommand ?
94012
Is it possible to mangle a Bash script such that it becomes unreadable by any human? If so, can it be de-mangled? Or, can I view what commands are being executed when I run the script?
112316
I am using Debian stretch (systemd). I was running the rsyslog daemon in foreground using /usr/sbin/rsyslogd -n and I did a Ctrl+Z to stop it.  The state of the process changed to Tl (stopped, threaded). I issued multiple kill -15 &lt;pid&gt; commands to the process, and the state of the process was the same: Tl. Once I did an fg, it died. I have 3 questions.   Why was the SIGSTOP-ed process not responding to SIGTERM? Why does the kernel keeps it in the same state?  Why did it get killed the moment it received the SIGCONT signal? If it was because of the previous SIGTERM signal, where was it kept until the process resumed?
32899
I want to start a programm with timeout, how can I kill the process using SIGINT and SIGKILL? If the programm not terminate within 5 seconds, send SIGINT. If it’s still running after 10 seconds (in total), send SIGKILL.  I already did timeout -s SIGINT nano; timeout -s SIGKILL nano but its not working, can somebody help me?
91218
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 just kills COMMAND and not the entire loop.  How would I achieve something similar but which I can stop without having to close the terminal?
106558
I'd like to automatically kill a command after a certain amount of time.  I have in mind an interface like this:  % constrain 300 ./foo args   Which would run "./foo" with "args" but automatically kill it if it's still running after 5 minutes.  It might be useful to generalize the idea to other constraints, such as autokilling a process if it uses too much memory.  Are there any existing tools that do that, or has anyone written such a thing?  ADDED: Jonathan's solution is precisely what I had in mind and it works like a charm on linux, but I can't get it to work on Mac OSX.  I got rid of the SIGRTMIN which lets it compile fine, but the signal just doesn't get sent to the child process.  Anyone know how to make this work on Mac?  [Added: Note that an update is available from Jonathan that works on Mac and elsewhere.]
92398
Is there any way to get a core dump of, or be able to debug a process that has been killed by oom-killer?  Or even set oom-killer to try to kill a process using ABRT instead?
38007
How can you suppress the Terminated message that comes up after you kill a process in a bash script?  I tried set +bm, but that doesn't work.  I know another solution involves calling exec 2&gt; /dev/null, but is that reliable? How do I reset it back so that I can continue to see stderr?
16228
Suppose a shell script (/bin/sh or /bin/bash) contained several commands.  How can I cleanly make the script terminate if any of the commands has a failing exit status?  Obviously, one can use if blocks and/or callbacks, but is there a cleaner, more concise way?  Using &amp;&amp; is not really an option either, because the commands can be long, or the script could have non-trivial things like loops and conditionals.