Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2002 05:56:02 -0700 (PDT)
From:      David Xu <davidxu@FreeBSD.org>
To:        cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/sys/sys proc.h src/sys/kern kern_sig.c kern_thread.c
Message-ID:  <200209031256.g83Cu2n3004143@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
davidxu     2002/09/03 05:56:02 PDT

  Modified files:
    sys/sys              proc.h 
    sys/kern             kern_sig.c kern_thread.c 
  Log:
  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)
  
  Revision  Changes    Path
  1.185     +27 -1     src/sys/kern/kern_sig.c
  1.18      +32 -6     src/sys/kern/kern_thread.c
  1.240     +2 -0      src/sys/sys/proc.h

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209031256.g83Cu2n3004143>