summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* break loop early if we know that there are at least two signals.David Xu2006-12-251-1/+2
| | | | Notes: svn path=/head/; revision=165537
* Merge posix4/* into normal kernel hierarchy.Tom Rhodes2006-11-111-2/+1
| | | | | | | | Reviewed by: glanced at by jhb Approved by: silence on -arch@ and -standards@ Notes: svn path=/head/; revision=164184
* Make KSE a kernel option, turned on by default in all GENERICJohn Birrell2006-10-261-0/+60
| | | | | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@ Notes: svn path=/head/; revision=163709
* Use macro TAILQ_FOREACH_SAFE instead of expanding it.David Xu2006-10-221-6/+3
| | | | Notes: svn path=/head/; revision=163601
* Remove the check that prevented signals from being delivered to exitingJohn Baldwin2006-10-201-3/+1
| | | | | | | | | | | | | | | | | processes. It was originally added back when support for Linux threads (and thus shared sigacts objects) was added, but no one knows why. My guess is that at some point during the Linux threads patches, the sigacts object was torn down during exit1(), so this check was added to prevent a panic for that race. However, the stuff that was actually committed to the tree doesn't teardown sigacts until wait() making the above race moot. Re-allowing signals here lets one interrupt a NFS request during process teardown (such as closing descriptors) on an interruptible mount. Requested by: kib (long time ago) MFC after: 1 week Notes: svn path=/head/; revision=163541
* Move some declaration of 32-bit signal structures into fileDavid Xu2006-10-051-3/+1
| | | | | | | freebsd32-signal.h, implement sigtimedwait and sigwaitinfo system calls. Notes: svn path=/head/; revision=163018
* Remove various bits of conditional Alpha code and fixup a few comments.John Baldwin2006-05-121-5/+1
| | | | Notes: svn path=/head/; revision=158471
* Call vn_finished_write() before calling the coredump handler which willTor Egge2006-05-071-1/+1
| | | | | | | indirectly call vn_start_write() as necessary for each write. Notes: svn path=/head/; revision=158351
* Don't try to kill embryonic processes in killpg1(). This preventsPaul Saab2006-04-211-2/+3
| | | | | | | | | | | a race condition between fork() and kill(pid,sig) with pid < 0 that can cause a kernel panic. Submitted by: up MFC after: 3 weeks Notes: svn path=/head/; revision=157948
* - Conditionalize Giant around VFS operations for ALQ, ktrace, andJohn Baldwin2006-03-281-13/+12
| | | | | | | | | | | generating a coredump as the result of a signal. - Fix a bug where we could leak a Giant lock if vn_start_write() failed in coredump(). Reported by: jmg (2) Notes: svn path=/head/; revision=157233
* Remove _STOPEVENT call, it is already called in issignal, simplifyDavid Xu2006-03-091-6/+1
| | | | | | | code for SIGKILL signal. Notes: svn path=/head/; revision=156472
* Add signal set sq_kill to sigqueue structure, the member saves allDavid Xu2006-03-021-3/+23
| | | | | | | | signals sent by kill() syscall, without this, a signal sent by sigqueue() can cause a signal sent by kill() to be lost. Notes: svn path=/head/; revision=156213
* 1. Refine kern_sigtimedwait() to remove redundant code.David Xu2006-02-231-31/+43
| | | | | | | | | | 2. Fix a bug, if thread got a SIGKILL signal, call sigexit() to kill its process. MFC after: 3 days Notes: svn path=/head/; revision=155947
* Code cleanup, simply compare with curproc.David Xu2006-02-231-2/+1
| | | | Notes: svn path=/head/; revision=155940
* Fix a long standing race between sleep queue and threadDavid Xu2006-02-151-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | suspension code. When a thread A is going to sleep, it calls sleepq_catch_signals() to detect any pending signals or thread suspension request, if nothing happens, it returns without holding process lock or scheduler lock, this opens a race window which allows thread B to come in and do process suspension work, however since A is still at running state, thread B can do nothing to A, thread A continues, and puts itself into actually sleeping state, but B has never seen it, and it sits there forever until B is woken up by other threads sometimes later(this can be very long delay or never happen). Fix this bug by forcing sleepq_catch_signals to return with scheduler lock held. Fix sleepq_abort() by passing it an interrupted code, previously, it worked as wakeup_one(), and the interruption can not be identified correctly by sleep queue code when the sleeping thread is resumed. Let thread_suspend_check() returns EINTR or ERESTART, so sleep queue no longer has to use SIGSTOP as a hack to build a return value. Reviewed by: jhb MFC after: 1 week Notes: svn path=/head/; revision=155741
* Audit the arguments to the kill(2) and killpg(2) system calls.Wayne Salamon2006-02-141-0/+7
| | | | | | | | Obtained from: TrustedBSD Project Approved by: rwatson (mentor) Notes: svn path=/head/; revision=155633
* In order to speed up process suspension on MP machine, send IPI toDavid Xu2006-02-131-31/+29
| | | | | | | | | remote CPU. While here, abstract thread suspension code into a function called sig_suspend_threads, the function is called when a process received a STOP signal. Notes: svn path=/head/; revision=155594
* Create childproc_jobstate function to report job control state, thisDavid Xu2006-02-041-42/+49
| | | | | | | also fixes a bug in childproc_continued which ignored PS_NOCLDSTOP. Notes: svn path=/head/; revision=155298
* Avoid kernel panic when attaching a process which may not be stoppedDavid Xu2005-12-241-2/+0
| | | | | | | | | | | | | by debugger, e.g process is dumping core. Only access p_xthread if P_STOPPED_TRACE is set, this means thread is ready to exchange signal with debugger, print a warning if P_STOPPED_TRACE is not set due to some bugs in other code, if there is. The patch has been tested by Anish Mistry mistry.7 at osu dot edu, and is slightly adjusted. Notes: svn path=/head/; revision=153697
* Add a sysctl to force a process to sigexit if a trap signal isDavid Xu2005-12-091-0/+17
| | | | | | | | | being hold by current thread or ignored by current process, otherwise, it is very possible the thread will enter an infinite loop and lead to an administrator's nightmare. Notes: svn path=/head/; revision=153264
* Cleanup sigqueue sysctl.David Xu2005-12-091-6/+2
| | | | Notes: svn path=/head/; revision=153252
* Fix a lock leak in childproc_continued().David Xu2005-12-061-1/+3
| | | | Notes: svn path=/head/; revision=153153
* set signal queue values for sysconf().David Xu2005-12-011-0/+4
| | | | Notes: svn path=/head/; revision=152975
* Make sure only remove one signal by debugger.David Xu2005-11-121-1/+2
| | | | Notes: svn path=/head/; revision=152327
* WIFxxx macros requires an int type but p_xstat is short, convert itDavid Xu2005-11-091-2/+3
| | | | | | | | | to int before using the macros. Bug reported by : Pyun YongHyeon pyunyh at gmail dot com Notes: svn path=/head/; revision=152223
* Add support for queueing SIGCHLD same as other UNIX systems did.David Xu2005-11-081-10/+87
| | | | | | | | | | | | | | | | | | | | | | | For each child process whose status has been changed, a SIGCHLD instance is queued, if the signal is stilling pending, and process changed status several times, signal information is updated to reflect latest process status. If wait() returns because the status of a child process is available, pending SIGCHLD signal associated with the child process is discarded. Any other pending SIGCHLD signals remain pending. The signal information is allocated at the same time when proc structure is allocated, if process signal queue is fully filled or there is a memory shortage, it can still send the signal to process. There is a booting time tunable kern.sigqueue.queue_sigchild which can control the behavior, setting it to zero disables the SIGCHLD queueing feature, the tunable will be removed if the function is proved that it is stable enough. Tested on: i386 (SMP and UP) Notes: svn path=/head/; revision=152185
* Fix name compatible problem with POSIX standard. the sigval_ptr andDavid Xu2005-11-041-1/+1
| | | | | | | | | sigval_int really should be sival_ptr and sival_int. Also sigev_notify_function accepts a union sigval value but not a pointer. Notes: svn path=/head/; revision=152029
* Cleanup some signal interfaces. Now the tdsignal function acceptsDavid Xu2005-11-031-45/+50
| | | | | | | | | | | | both proc pointer and thread pointer, if thread pointer is NULL, tdsignal automatically finds a thread, otherwise it sends signal to given thread. Add utility function psignal_event to send a realtime sigevent to a process according to the delivery requirement specified in struct sigevent. Notes: svn path=/head/; revision=151993
* Let itimer store itimerspec instead of itimerval, so I don't have toDavid Xu2005-10-301-1/+5
| | | | | | | | | | | | | | | | | | | | | | convert to or from timeval frequently. Introduce function itimer_accept() to ack a timer signal in signal acceptance code, this allows us to return more fresh overrun counter than at signal generating time. while POSIX says: "the value returned by timer_getoverrun() shall apply to the most recent expiration signal delivery or acceptance for the timer,.." I prefer returning it at acceptance time. Introduce SIGEV_THREAD_ID notification mode, it is used by thread libary to request kernel to deliver signal to a specified thread, and in turn, the thread library may use the mechanism to implement SIGEV_THREAD which is required by POSIX. Timer signal is managed by timer code, so it can not fail even if signal queue is full filled by sigqueue syscall. Notes: svn path=/head/; revision=151869
* 1. Make ksiginfo_alloc and ksiginfo_free public.David Xu2005-10-231-12/+58
| | | | | | | | | 2. Introduce flags KSI_EXT and KSI_INS. The flag KSI_EXT allows a ksiginfo to be managed by outside code, the KSI_INS indicates sigqueue_add should directly insert passed ksiginfo into queue other than copy it. Notes: svn path=/head/; revision=151575
* 1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, mostDavid Xu2005-10-141-172/+503
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changes in MD code are trivial, before this change, trapsignal and sendsig use discrete parameters, now they uses member fields of ksiginfo_t structure. For sendsig, this change allows us to pass POSIX realtime signal value to user code. 2. Remove cpu_thread_siginfo, it is no longer needed because we now always generate ksiginfo_t data and feed it to libpthread. 3. Add p_sigqueue to proc structure to hold shared signals which were blocked by all threads in the proc. 4. Add td_sigqueue to thread structure to hold all signals delivered to thread. 5. i386 and amd64 now return POSIX standard si_code, other arches will be fixed. 6. In this sigqueue implementation, pending signal set is kept as before, an extra siginfo list holds additional siginfo_t data for signals. kernel code uses psignal() still behavior as before, it won't be failed even under memory pressure, only exception is when deleting a signal, we should call sigqueue_delete to remove signal from sigqueue but not SIGDELSET. Current there is no kernel code will deliver a signal with additional data, so kernel should be as stable as before, a ksiginfo can carry more information, for example, allow signal to be delivered but throw away siginfo data if memory is not enough. SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can not be caught or masked. The sigqueue() syscall allows user code to queue a signal to target process, if resource is unavailable, EAGAIN will be returned as specification said. Just before thread exits, signal queue memory will be freed by sigqueue_flush. Current, all signals are allowed to be queued, not only realtime signals. Earlier patch reviewed by: jhb, deischen Tested on: i386, amd64 Notes: svn path=/head/; revision=151316
* Fix a bug relavant to debugging, a masked signal unexpectedly interruptsDavid Xu2005-06-061-52/+37
| | | | | | | | | | a sleeping thread when process is being debugged. PR: GNU/77818 Tested by: Sean C. Farley <sean-freebsd at farley org> Notes: svn path=/head/; revision=147046
* Oops, forgot to update this file.David Xu2005-04-191-17/+9
| | | | | | | | | | | | | | Fix a race condition between kern_wait() and thread_stopped(). Problem is in kern_wait(), parent process steps through children list, once a child process is skipped, and later even if the child is stopped, parent process still sleeps in msleep(), the race happens if parent masked SIGCHLD. Submitted by : Peter Edwards peadar.edwards at gmail dot com MFC after : 4 days Notes: svn path=/head/; revision=145261
* Suspend all other threads in the process while generating a core dump.David Schultz2005-04-101-1/+11
| | | | | | | | | | | | | | | The main reason for doing this is that the ELF dump handler expects the thread list to be fixed while the dump header is generated, so an upcall that occurs at the wrong time can lead to buffer overruns and other Bad Things. Another solution would be to grab sched_lock in the ELF dump handler, but we might as well single-thread, since the process is about to die. Furthermore, I think this should ensure that the register sets in the core file are sequentially consistent. Notes: svn path=/head/; revision=144851
* The td_waitset is pointing to a stack address when thread is waitingDavid Xu2005-03-041-19/+6
| | | | | | | | | for a signal, because kernel stack is swappable, this causes page fault in kernel under heavy swapping case. Fix this bug by eliminating unneeded code. Notes: svn path=/head/; revision=143144
* In kern_sigtimedwait, remove waitset bits for td_sigmask beforeDavid Xu2005-03-021-28/+10
| | | | | | | | | | | | sleeping, so in do_tdsignal, we no longer need to test td_waitset. now td_waitset is only used to give a thread higher priority when delivering signal to multithreads process. This also fixes a bug: when a thread in sigwait states was suspended and later resumed by SIGCONT, it can no longer receive signals belong to waitset. Notes: svn path=/head/; revision=143033
* Don't restart a timeout wait in kern_sigtimedwait, also allow itDavid Xu2005-02-191-11/+27
| | | | | | | to wait longer than a single integer can represent. Notes: svn path=/head/; revision=142072
* Backout previous change (disabling of security checks for signals deliveredMaxim Sobolev2005-02-131-22/+11
| | | | | | | | | in emulation layers), since it appears to be too broad. Requested by: rwatson Notes: svn path=/head/; revision=141815
* Split out kill(2) syscall service routine into user-level and kernel part, theMaxim Sobolev2005-02-131-11/+22
| | | | | | | | | | | | | | | | | | | | former is callable from user space and the latter from the kernel one. Make kernel version take additional argument which tells if the respective call should check for additional restrictions for sending signals to suid/sugid applications or not. Make all emulation layers using non-checked version, since signal numbers in emulation layers can have different meaning that in native mode and such protection can cause misbehaviour. As a result remove LIBTHR from the signals allowed to be delivered to a suid/sugid application. Requested (sorta) by: rwatson MFC after: 2 weeks Notes: svn path=/head/; revision=141812
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139804
* - If delivering a signal will result in killing a process that has aJeff Roberson2004-12-131-0/+2
| | | | | | | | | nice value above 0, set it to 0 so that it may proceed with haste. This is especially important on ULE, where adjusting the priority does not guarantee that a thread will be granted a greater time slice. Notes: svn path=/head/; revision=138811
* Fix an off by one error. MAXPATHLEN already has +1.Warner Losh2004-11-151-1/+1
| | | | Notes: svn path=/head/; revision=137746
* Allow kill -9 to kill processes stuck in procfs STOPEVENTs.Alfred Perlstein2004-10-301-0/+10
| | | | Notes: svn path=/head/; revision=137058
* Backout 1.291.Alfred Perlstein2004-10-291-10/+0
| | | | | | | | re doesn't seem to think this fixes: Desired features for 5.3-RELEASE "More truss problems" Notes: svn path=/head/; revision=137030
* Use scheduler api to adjust thread priority.David Xu2004-10-051-2/+3
| | | | Notes: svn path=/head/; revision=136142
* Don't bother to turn off other P_STOPPED bits for SIGKILL, doingDavid Xu2004-10-031-1/+1
| | | | | | | | | so would cause kernel to produce an unkillable process in some cases, especially, P_STOPPED_SINGLE has a singling thread, turning off the bit would mess the state. Notes: svn path=/head/; revision=136086
* Clear a process's procfs trace points upon delivery of SIGKILL.Alfred Perlstein2004-10-011-0/+10
| | | | | | | MT5 candidate. (Desired features for 5.3-RELEASE "More truss problems") Notes: svn path=/head/; revision=136024
* Remove an unneeded argument..Julian Elischer2004-08-311-1/+1
| | | | | | | | | | | | The removed argument could trivially be derived from the remaining one. That in turn should be the same as curthread, but it is possible that curthread could be expensive to derive on some syste,s so leave it as an argument. Having both proc and thread as an argumen tjust gives an opportunity for them to get out sync. MFC after: 3 days Notes: svn path=/head/; revision=134571
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemJohn-Mark Gurney2004-08-151-7/+3
| | | | | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions) Notes: svn path=/head/; revision=133741
* add option to automaticly mark core dumps with the nodump flagJohn-Mark Gurney2004-08-091-0/+6
| | | | | | | | PR: 57065 Submitted by: Walter C. Pelissero Notes: svn path=/head/; revision=133354