On 27/03/2021 14:27, Janis Papanagnou wrote:
> On 27.03.2021 15:07, Ottavio Caruso wrote:
>> On 27/03/2021 13:27, Janis Papanagnou wrote:
>>>
>>> Generally I also observe sometimes processes that can't be killed in
>>> shell by ^C etc.; some processes or executed tasks may have disabled
>>> handling of SIGINT, or maybe it's something different, hard to tell.
>>> Is it the terminal or one of processes that catches these signals?
>>> So my first try would be to send a SIGINT from outside not a SIGKILL.
>>> What event is the process waiting for; inspecting the syslog may help
>>> here.
>>
>> If by SIGINT you mean a standard kill, it doesn't work.
>
> kill without option is SIGTERM (15), SIGINT is 2, SIGQUIT is 3; all
> these signals (as opposed to e.g. SIGKILL (9)) can be intercepted
> and handled by processes. I meant to try 'kill -2' (SIGINT, that is
> on terminals usually available as Ctrl-C (^C)).
First of all, I have now used a different function:
gen_text2 ()
{
tr -dc "$1" < /dev/urandom | head -c "$2";
printf "\n"
}
$ gen_text2 "cb?dw4lh+8@px,1y-" 186 | morse -f `echo $RANDOM % 400 +
500 | bc` -ecTsB -w 15 -n 19
^C^C^C^C^C^Z^Z^Z^Z^Z^\^\^\^\^\^\^\^C^C
In another terminal tab:
$ ps aux|grep morse
oc 11356 0.0 0.1 439780 5120 pts/5 Sl+ 14:34 0:00 morse
-f 878 -ecTsB -w 15 -n 19
oc 11387 0.0 0.0 6076 892 pts/6 S+ 14:36 0:00 grep
--color=auto morse
$ kill -2 11356
Nope!
$ tail /var/log/syslog
$ tail /var/log/messages
Nothing relevant.
>
>> The process must
>> be killed mercilessly with `kill -9`. I've checked both
>> /var/log/messages and /var/log/syslog, but nothing gets written there.
>>
>>
>> Then I'd approach the issue by simplifying the code to find the
>>> source. Simplifying steps can be to replace the '`...|bc`' complexity
>>> by a simple shell arithmetic expression 'morse $((RANDOM ...))'. And
>>> as another step omit all unnecessary options to localize the issue.
>>> (Adding options one by one later to see if some option may change the
>>> behavior.) And also simplify the input; use a 'printf' instead of a
>>> pipe expression (specifically if you rely on /dev/urandom) and omit
>>> the function call.
>>
>> I'll give a look at that. Somebody wrote that function for me some time
>> ago and I just used without much understanding of it, to be completely
>> honest.
>
> The tests should start simple without that function
>
> echo "Hello" | morse $((RANDOM % 400 + 500))
>
> Then introduce a function but without using the 'urandom' device.
> And so on. If questions arise on the way feel free to ask.
>
> Janis
>
$ echo "Hello" | morse $((RANDOM % 400 + 500))
^C^C^C^C^C^C^C^C^C^Z^Z^Z^Z^Z^\^\^\^\^\^\
$ ps aux|grep morse
oc 11477 0.2 0.1 439780 5028 pts/6 Sl+ 14:40 0:00 morse 630
oc 11481 0.0 0.0 6076 892 pts/7 S+ 14:40 0:00 grep
--color=auto morse
$ kill -2 11477
Nope again.
I've checked on the Debian package search. Both Stretch and Buster use
the same version of morse, so nothing has changed in the source code.
-
Ottavio Caruso