瀏覽代碼

* save/restore errno inside reenable_signal, because it can be called
from inside signal handlers

git-svn-id: trunk@12997 -

Jonas Maebe 16 年之前
父節點
當前提交
1f6ec36064
共有 5 個文件被更改,包括 21 次插入1 次删除
  1. 4 0
      rtl/beos/system.pp
  2. 4 0
      rtl/bsd/system.pp
  3. 5 1
      rtl/haiku/system.pp
  4. 4 0
      rtl/linux/system.pp
  5. 4 0
      rtl/solaris/system.pp

+ 4 - 0
rtl/beos/system.pp

@@ -298,6 +298,7 @@ function  reenable_signal(sig : longint) : boolean;
 var
 var
   e : TSigSet;
   e : TSigSet;
   i,j : byte;
   i,j : byte;
+  olderrno: cint;
 begin
 begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   { set is 1 based PM }
   { set is 1 based PM }
@@ -305,8 +306,11 @@ begin
   i:=sig mod (sizeof(cuLong) * 8);
   i:=sig mod (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   e[j]:=1 shl i;
   e[j]:=1 shl i;
+  { this routine is called from a signal handler, so must not change errno }
+  olderrno:=geterrno;
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;
+  seterrno(olderrno);
 end;
 end;
 
 
 // signal handler is arch dependant due to processorexception to language
 // signal handler is arch dependant due to processorexception to language

+ 4 - 0
rtl/bsd/system.pp

@@ -153,6 +153,7 @@ function  reenable_signal(sig : longint) : boolean;
 var
 var
   e,oe : TSigSet;
   e,oe : TSigSet;
   i,j : byte;
   i,j : byte;
+  olderrno: cint;
 begin
 begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   fillchar(oe,sizeof(oe),#0);
   fillchar(oe,sizeof(oe),#0);
@@ -161,8 +162,11 @@ begin
   i:=sig mod 32;
   i:=sig mod 32;
   j:=sig div 32;
   j:=sig div 32;
   e[j]:=1 shl i;
   e[j]:=1 shl i;
+  { this routine is called from a signal handler, so must not change errno }
+  olderrno:=geterrno;
   fpsigprocmask(SIG_UNBLOCK,@e,@oe);
   fpsigprocmask(SIG_UNBLOCK,@e,@oe);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;
+  seterrno(olderrno);
 end;
 end;
 
 
 {$i sighnd.inc}
 {$i sighnd.inc}

+ 5 - 1
rtl/haiku/system.pp

@@ -298,6 +298,7 @@ function  reenable_signal(sig : longint) : boolean;
 var
 var
   e : TSigSet;
   e : TSigSet;
   i,j : byte;
   i,j : byte;
+  olderrno: cint;
 begin
 begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   { set is 1 based PM }
   { set is 1 based PM }
@@ -305,8 +306,11 @@ begin
   i:=sig mod (sizeof(cuLong) * 8);
   i:=sig mod (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   e[j]:=1 shl i;
   e[j]:=1 shl i;
+  { this routine is called from a signal handler, so must not change errno }
+  olderrno:=geterrno;
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;
+  seterrno(olderrno);
 end;
 end;
 
 
 // signal handler is arch dependant due to processorexception to language
 // signal handler is arch dependant due to processorexception to language
@@ -454,4 +458,4 @@ begin
   initunicodestringmanager;
   initunicodestringmanager;
 {$endif VER2_2}
 {$endif VER2_2}
   setupexecname;
   setupexecname;
-end.
+end.

+ 4 - 0
rtl/linux/system.pp

@@ -216,6 +216,7 @@ function  reenable_signal(sig : longint) : boolean;
 var
 var
   e : TSigSet;
   e : TSigSet;
   i,j : byte;
   i,j : byte;
+  olderrno: cint;
 begin
 begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   { set is 1 based PM }
   { set is 1 based PM }
@@ -223,8 +224,11 @@ begin
   i:=sig mod (sizeof(cuLong) * 8);
   i:=sig mod (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   j:=sig div (sizeof(cuLong) * 8);
   e[j]:=1 shl i;
   e[j]:=1 shl i;
+  { this routine is called from a signal handler, so must not change errno }
+  olderrno:=geterrno;
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   fpsigprocmask(SIG_UNBLOCK,@e,nil);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;
+  seterrno(olderrno);
 end;
 end;
 
 
 // signal handler is arch dependant due to processorexception to language
 // signal handler is arch dependant due to processorexception to language

+ 4 - 0
rtl/solaris/system.pp

@@ -103,6 +103,7 @@ function  reenable_signal(sig : longint) : boolean;
 var
 var
   e,oe : TSigSet;
   e,oe : TSigSet;
   i,j : byte;
   i,j : byte;
+  olderrno: cint;
 begin
 begin
   fillchar(e,sizeof(e),#0);
   fillchar(e,sizeof(e),#0);
   fillchar(oe,sizeof(oe),#0);
   fillchar(oe,sizeof(oe),#0);
@@ -111,8 +112,11 @@ begin
   i:=sig mod 32;
   i:=sig mod 32;
   j:=sig div 32;
   j:=sig div 32;
   e[j]:=1 shl i;
   e[j]:=1 shl i;
+  { this routine is called from a signal handler, so must not change errno }
+  olderrno:=geterrno;
   fpsigprocmask(SIG_UNBLOCK,@e,@oe);
   fpsigprocmask(SIG_UNBLOCK,@e,@oe);
   reenable_signal:=geterrno=0;
   reenable_signal:=geterrno=0;
+  seterrno(olderrno);
 end;
 end;
 
 
 {$i sighnd.inc}
 {$i sighnd.inc}