2014-12-18 12:15 GMT-02:00 Paulo César Pereira de Andrade
<[email protected]>:
[snip]
The test case:
---8<---
#!/bin/ksh
toto="s"
alarm -r alarm_handler +1
function alarm_handler.alarm
{
if [[ $toto == "s" ]]
then
toto="e"
else
toto="f"
fi
}
IFS=","
(echo "2";sleep 1;echo "3") | while IFS="," read arg1
#(echo "2";sleep 1;echo "3") | while read arg1
do
print "$arg1"
done
---8<---
I believe this is a better patch, it save/restore way less
state than sh_trap, as I am unsure about issues if
adding a "struct checkpt" to sh_pushcontext/sh_popcontext,
or using stacktell&stakfreeze/stakset.
The attached patch corrects the test case, and otherwise
should have the same behavior as before regarding to
faults in an alarm function.
Thanks!
Paulo
diff -up ksh-20120801/src/cmd/ksh93/bltins/alarm.c.orig ksh-20120801/src/cmd/ksh93/bltins/alarm.c
--- ksh-20120801/src/cmd/ksh93/bltins/alarm.c.orig 2014-12-22 11:42:51.474118920 -0200
+++ ksh-20120801/src/cmd/ksh93/bltins/alarm.c 2014-12-22 11:49:36.998778280 -0200
@@ -27,6 +27,7 @@
*/
#include "defs.h"
+#include <fcin.h>
#include <error.h>
#include <stak.h>
#include "builtins.h"
@@ -130,6 +131,8 @@ void sh_timetraps(Shell_t *shp)
{
register struct tevent *tp, *tpnext;
register struct tevent *tptop;
+ char ifstable[256];
+ Fcin_t savefc;
while(1)
{
shp->sigflag[SIGALRM] &= ~SH_SIGALRM;
@@ -141,7 +144,13 @@ void sh_timetraps(Shell_t *shp)
{
tp->flags &= ~L_FLAG;
if(tp->action)
+ {
+ fcsave(&savefc);
+ memcpy(ifstable,shp->ifstable,sizeof(ifstable));
sh_fun(tp->action,tp->node,(char**)0);
+ fcrestore(&savefc);
+ memcpy(shp->ifstable,ifstable,sizeof(ifstable));
+ }
tp->flags &= ~L_FLAG;
if(!tp->flags)
{
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users