This problem is specific to all releases, and fedora, up
A simple test case is:
alarm -r alarm_handler +1
if [[ $toto == "s" ]]
(echo "2";sleep 1;echo "3") | while IFS="," read arg1
#(echo "2";sleep 1;echo "3") | while read arg1
There is a small thread about it at
I had made an initial one liner patch that address
specifically the problem, but I was not happy with
it because it probably would just hide other issues
that may arise from alarms.
Anyway, I will only propose a simple patch for
cases where there are no exceptions involved.
This was an off list reply I received:
Subject: Re: [ast-users] [PATCH] Problem with alarm and IFS
From: David Korn <firstname.lastname@example.org>
To: =?UTF-8?Q?Paulo_C=C3=A9sar_Pereira_de_Andrade?= <email@example.com>
Content-Type: multipart/alternative; boundary=001a113ab2ba6fd291050a9c0dcd
Content-Type: text/plain; charset=UTF-8
I never documented the alarm builtin because it is problematic. The
problem is that traps can't safely be handled asynchronously. What should
happen is that the trap is marked for execution (sh_trapnote) and run after
the current command completes. The time trap should wake up the shell if
it is blocked and it should return and then handle the trap.
That being said, I will pick up both of our patches since they don't do
harm and improve the undocumented alarm builtin.
Created attachment 972117 [details]
This is the patch I propose to be applied on
rhel and fedora ksh packages.
Created attachment 972118 [details]
Minimal one liner patch that correct the problem.
This patch should be in upstream ksh now.
Created attachment 972126 [details]
Alternate simple patch, that should also be in upstream
now. This is a slightly simpler version of
I don't understand it clearly from the comments. What patches were included upstream? Both 2 and 3?
Sorry for somewhat confusing patches attached.
The two patches named ksh-20120801-ifstable.patch
should be in upstream, either corrects the
problem (one overwrites the test condition that
would cause an infinite loop, the other save
and restore the ifstable during the alarm).
There is no newer tarball at
so I cannot confirm to be 100% sure it has been
added. The email from David Korn I did cut&paste
is talking about the two patches named
ksh-20120801-ifstable.patch that were posted
to ast-users mailing list.
The patch named ksh-20120801-alarm.patch
is an attempt to save&restore more state in an alarm,
but is likely incomplete, that is, there may be
other states that should be save/restored for
possible other issues, like exceptions, during the
alarm, but no known test case.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.