freebsd-skq/sys
davidxu de678b0952 In the kernel code, we have the tsleep() call with the PCATCH argument.
PCATCH means 'if we get a signal, interrupt me!" and tsleep returns
either EINTR or ERESTART depending on the circumstances.  ERESTART is
"special" because it causes the system call to fail, but right as it
returns back to userland it tells the trap handler to move %eip back a
bit so that userland will immediately re-run the syscall.
This is a syscall restart. It only works for things like read() etc where
nothing has changed yet. Note that *userland* is tricked into restarting
the syscall by the kernel. The kernel doesn't actually do the restart. It
is deadly for things like select, poll, nanosleep etc where it might cause
the elapsed time to be reset and start again from scratch.  So those
syscalls do this to prevent userland rerunning the syscall:
  if (error == ERESTART) error = EINTR;

Fake "signals" like SIGTSTP from ^Z etc do not normally invoke userland
signal handlers. But, in -current, the PCATCH *is* being triggered and
tsleep is returning ERESTART, and the syscall is aborted even though no
userland signal handler was run.
That is the fault here.  We're triggering the PCATCH in cases that we
shouldn't.  ie: it is being triggered on *any* signal processing, rather
than the case where the signal is posted to userland.
	--- Peter

The work of psignal() is a patchwork of special case required by the process
debugging and job-control facilities...
	--- Kirk McKusick
	"The design and impelementation of the 4.4BSD Operating system"
	Page 105

in STABLE source, when psignal is posting a STOP signal to sleeping
process and the signal action of the process is SIG_DFL, system will
directly change the process state from SSLEEP to SSTOP, and when
SIGCONT is posted to the stopped process, if it finds that the process
is still on sleep queue, the process state will be restored to SSLEEP,
and won't wakeup the process.

this commit mimics the behaviour in STABLE source tree.

Reviewed by: Jon Mini, Tim Robbins, Peter Wemm
Approved by: julian@freebsd.org (mentor)
2002-09-03 12:56:01 +00:00
..
alpha Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all 2002-09-03 00:06:58 +00:00
amd64 Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to 2002-09-01 21:41:24 +00:00
arm Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all 2002-09-03 00:06:58 +00:00
boot Make SCSI_DELAY setable at boot time and runtime via the 2002-09-02 20:10:19 +00:00
cam Make SCSI_DELAY setable at boot time and runtime via the 2002-09-02 20:10:19 +00:00
coda Fix typo in the last revision. 2002-08-04 19:34:38 +00:00
compat Use the new kern_*() functions to avoid using the stack gap in 2002-09-02 22:46:05 +00:00
conf Hook up libkern/strlcpy.c and libkern/strlcat.c after repocopy. 2002-09-02 20:16:22 +00:00
contrib Fix kernel build breakage when ACPI_DEBUG option is specified. 2002-08-29 08:31:06 +00:00
crypto Fix some really pedantic GCC warnings. 2002-07-15 13:45:15 +00:00
ddb db_ps.c: 2002-08-31 04:25:44 +00:00
dev Remove a debug printf. 2002-09-03 11:31:34 +00:00
fs Add a missing #include <sys/lockmgr.h>. 2002-09-01 23:02:10 +00:00
geom Use 'p' as the partition specifier instead of 's'. We continue to use 2002-08-24 22:42:16 +00:00
gnu In order to better support flexible and extensible access control, 2002-08-15 20:55:08 +00:00
i4b Continue de-counting i4b. Devices i4bctl, i4bcapi, iavc, i4bq921, 2002-09-02 00:52:11 +00:00
i386 Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all 2002-09-03 00:06:58 +00:00
ia64 Make this compile 2002-09-03 04:30:00 +00:00
isa Add suspend/resume method to syscons. This switch the mode 2002-08-25 18:35:44 +00:00
isofs/cd9660 Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
kern In the kernel code, we have the tsleep() call with the PCATCH argument. 2002-09-03 12:56:01 +00:00
libkern Include sys/libkern.h for the kernel prototypes of these libkern functions 2002-08-22 20:08:07 +00:00
modules Add cleandepend target. 2002-08-31 17:15:43 +00:00
net Fix a silly typo in user-setable promisc mode code. 2002-08-30 13:37:13 +00:00
netatalk Introduce experimental support for MAC in the AppleTalk/EtherTalk stack. 2002-08-15 18:58:44 +00:00
netatm Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
netgraph Don't use "NULL" when "0" is really meant. 2002-08-22 00:30:03 +00:00
netinet some ipfilter files that accidently got imported here 2002-08-29 13:27:26 +00:00
netinet6 Lock the sysctl(8) knobs that turn ip{,6}fw(8) firewalling and 2002-08-25 03:50:29 +00:00
netipx Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
netkey - fixed the order of searching SA table for packets. 2002-07-10 16:39:38 +00:00
netnatm Back out my lats commit of locking down a socket, it conflicts with hsu's work. 2002-05-31 11:52:35 +00:00
netncp Wire the sysctl output buffer before grabbing any locks to prevent 2002-07-28 19:59:31 +00:00
netns Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
netsmb <sys/lock.h> is a prerequisite for <sys/mutex.h>, so include the former 2002-08-27 12:22:06 +00:00
nfs
nfsclient Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid 2002-08-18 07:05:00 +00:00
nfsserver Make the V2 errno translation more resistent to new errnos. 2002-08-21 19:28:44 +00:00
pc98 Take a shot at fixing up a whole stack of style and other embarresing 2002-08-31 03:33:32 +00:00
pccard Add 16-bit before bus to keep the words card and bus apart. 2002-07-31 20:01:11 +00:00
pci Add a device description for Intel 82801CA/CAM (ICH3) USB controller 2002-08-28 20:24:49 +00:00
posix4 Part 1 of KSE-III 2002-06-29 17:26:22 +00:00
powerpc Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all 2002-09-03 00:06:58 +00:00
rpc
security Prefer NULL to 0 when passing a NULL pointer. 2002-08-20 02:54:09 +00:00
sparc64 Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all 2002-09-03 00:06:58 +00:00
sys In the kernel code, we have the tsleep() call with the PCATCH argument. 2002-09-03 12:56:01 +00:00
tools - Add two new debugging macros: ASSERT_VI_LOCKED and ASSERT_VI_UNLOCKED 2002-08-21 06:19:29 +00:00
ufs Since we have vp and td cached in local variables, use those instead 2002-09-01 16:06:40 +00:00
vm o Synchronize updates to struct vm_page::cow with the page queues lock. 2002-09-02 04:04:12 +00:00
Makefile Milestone #1 in cross-arch make releases. 2002-04-26 17:55:27 +00:00