On Ubuntu 22.10, I'm using the following shipped bash version:
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -o pgid= $$ | egrep -o [0-9]+); exit 1' 2
Then when the script is running, when I hit the control-c,
I just noticed the following information given on the screen:
blabla (Here is the normal information given by the script when running).
^C
This issue did not occur until I upgraded to this version of the
operating system. I'm very confused by this behavior.
On Ubuntu 22.10, I'm using the following shipped bash version:
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -o
pgid= $$ | egrep -o [0-9]+); exit 1' 2
Then when the script is running, when I hit the control-c, I just
noticed the following information given on the screen:
blabla (Here is the normal information given by the script when
running). ^C
This issue did not occur until I upgraded to this version of the
operating system. I'm very confused by this behavior.
Hi here,
On Ubuntu 22.10, I'm using the following shipped bash version:
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -o pgid= $$ | egrep -o [0-9]+); exit 1' 2
Then when the script is running, when I hit the control-c, I just noticed the following information given on the screen:
blabla (Here is the normal information given by the script when running).
^C
This issue did not occur until I upgraded to this version of the operating system. I'm very confused by this behavior.
Any comments and tips will be appreciated.
Regards,
Zhao
"[email protected]" <[email protected]> writes:
On Ubuntu 22.10, I'm using the following shipped bash version:
$ bash --versionSame here.
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -oWhat's all the ps and egrep stuff for? Isn't the net effect just $$?
pgid= $$ | egrep -o [0-9]+); exit 1' 2
Then when the script is running, when I hit the control-c, I just
noticed the following information given on the screen:
blabla (Here is the normal information given by the script when
running). ^C
This issue did not occur until I upgraded to this version of thePresumably the issue is that the trap does not work, but it does for
operating system. I'm very confused by this behavior.
me. Is Ctrl-C sending the right signal?
Can you post a minimal example that fails for you? This example:
#!/bin/bash
trap 'echo -en "\n*** Ouch! Exiting ***\n"; exit 1' 2
while true; do
echo blah
done
works for me:
$ ./script
blah
blah
blah
blah
blah
blah
^C./script: line 6: echo: write error: Interrupted system call
*** Ouch! Exiting ***
--
Ben.
On Monday, December 5, 2022 at 12:13:50 AM UTC+8, Ben Bacarisse wrote:
"[email protected]" <[email protected]> writes:
On Ubuntu 22.10, I'm using the following shipped bash version:Same here.
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:What's all the ps and egrep stuff for? Isn't the net effect just $$?
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -o
pgid= $$ | egrep -o [0-9]+); exit 1' 2
I've a bunch of other processes spawned from this script, and I hope
to kill them all, so that the orphan process will not be left behind.
"[email protected]" <[email protected]> writes:
On Monday, December 5, 2022 at 12:13:50 AM UTC+8, Ben Bacarisse wrote:
"[email protected]" <[email protected]> writes:
On Ubuntu 22.10, I'm using the following shipped bash version:Same here.
$ bash --version
GNU bash, version 5.2.2(1)-release (x86_64-pc-linux-gnu)
In my case, I've a bash script which has the following line in it:What's all the ps and egrep stuff for? Isn't the net effect just $$?
trap 'echo -en "\n*** Ouch! Exiting ***\n"; sudo kill -- -$(ps -o
pgid= $$ | egrep -o [0-9]+); exit 1' 2
I've a bunch of other processes spawned from this script, and I hopeEd Morton called it! Did you read his reply?
to kill them all, so that the orphan process will not be left behind.
--
Ben.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 156:09:39 |
| Calls: | 12,092 |
| Files: | 15,000 |
| Messages: | 6,517,729 |