summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* - Calling sched_nice() in tdsigwakeup() is no longer required by ULE andjeff2007-07-191-6/+2
| | | | | | | actually causes LORs and other panics. Reported by: mlaier Approved by: re
* - Add a missing PROC_SUNLOCK() in tdsignal()jeff2007-06-111-1/+3
|
* Initialized ets to zero. This is arguably a gcc bug in that ets is alwaysmjacob2007-06-101-0/+2
| | | | | set to rts when timeout is non-NULL and then timevalid is set and ets is only checked later when timervalid is set.
* Commit 4/14 of sched_lock decomposition.jeff2007-06-041-56/+66
| | | | | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. - Move some common code into thread_suspend_switch() to handle the mechanics of suspending a thread. The locking here is incredibly convoluted and should be simplified. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* - Move rusage from being per-process in struct pstats to per-thread injeff2007-06-011-2/+2
| | | | | | | | | | | | | | | | | | | td_ru. This removes the requirement for per-process synchronization in statclock() and mi_switch(). This was previously supported by sched_lock which is going away. All modifications to rusage are now done in the context of the owning thread. reads proceed without locks. - Aggregate exiting threads rusage in thread_exit() such that the exiting thread's rusage is not lost. - Provide a new routine, rufetch() to fetch an aggregate of all rusage structures from all threads in a process. This routine must be used in any place requiring a rusage from a process prior to it's exit. The exited process's rusage is still available via p_ru. - Aggregate tick statistics only on demand via rufetch() or when a thread exits. Tick statistics are kept in the thread and protected by sched_lock until it exits. Initial patch by: attilio Reviewed by: attilio, bde (some objections), arch (mostly silent)
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-1/+1
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* Comment that tdsignal() may be entered from the debugger.rwatson2007-05-231-0/+4
|
* Rename the 'mtx_object', 'rw_object', and 'sx_object' members of mutexes,jhb2007-03-211-2/+2
| | | | rwlocks, and sx locks to 'lock_object'.
* Further system call comment cleanup:rwatson2007-03-051-12/+2
| | | | | | | | | | - Remove also "MP SAFE" after prior "MPSAFE" pass. (suggested by bde) - Remove extra blank lines in some cases. - Add extra blank lines in some cases. - Remove no-op comments consisting solely of the function name, the word "syscall", or the system call name. - Add punctuation. - Re-wrap some comments.
* Remove 'MPSAFE' annotations from the comments above most system calls: allrwatson2007-03-041-75/+8
| | | | | | | | system calls now enter without Giant held, and then in some cases, acquire Giant explicitly. Remove a number of other MPSAFE annotations in the credential code and tweak one or two other adjacent comments.
* Give which signal caller has attempted to deliver when panicking.delphij2007-02-091-2/+2
|
* Use FOREACH_PROC_IN_SYSTEM instead of using its unrolled form.delphij2007-01-171-1/+1
|
* break loop early if we know that there are at least two signals.davidxu2006-12-251-1/+2
|
* Merge posix4/* into normal kernel hierarchy.trhodes2006-11-111-2/+1
| | | | | Reviewed by: glanced at by jhb Approved by: silence on -arch@ and -standards@
* Make KSE a kernel option, turned on by default in all GENERICjb2006-10-261-0/+60
| | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@
* Use macro TAILQ_FOREACH_SAFE instead of expanding it.davidxu2006-10-221-6/+3
|
* Remove the check that prevented signals from being delivered to exitingjhb2006-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
* Move some declaration of 32-bit signal structures into filedavidxu2006-10-051-3/+1
| | | | freebsd32-signal.h, implement sigtimedwait and sigwaitinfo system calls.
* Remove various bits of conditional Alpha code and fixup a few comments.jhb2006-05-121-5/+1
|
* Call vn_finished_write() before calling the coredump handler which willtegge2006-05-071-1/+1
| | | | indirectly call vn_start_write() as necessary for each write.
* Don't try to kill embryonic processes in killpg1(). This preventsps2006-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
* - Conditionalize Giant around VFS operations for ALQ, ktrace, andjhb2006-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)
* Remove _STOPEVENT call, it is already called in issignal, simplifydavidxu2006-03-091-6/+1
| | | | code for SIGKILL signal.
* Add signal set sq_kill to sigqueue structure, the member saves alldavidxu2006-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.
* 1. Refine kern_sigtimedwait() to remove redundant code.davidxu2006-02-231-31/+43
| | | | | | | 2. Fix a bug, if thread got a SIGKILL signal, call sigexit() to kill its process. MFC after: 3 days
* Code cleanup, simply compare with curproc.davidxu2006-02-231-2/+1
|
* Fix a long standing race between sleep queue and threaddavidxu2006-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
* Audit the arguments to the kill(2) and killpg(2) system calls.wsalamon2006-02-141-0/+7
| | | | | Obtained from: TrustedBSD Project Approved by: rwatson (mentor)
* In order to speed up process suspension on MP machine, send IPI todavidxu2006-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.
* Create childproc_jobstate function to report job control state, thisdavidxu2006-02-041-42/+49
| | | | also fixes a bug in childproc_continued which ignored PS_NOCLDSTOP.
* Avoid kernel panic when attaching a process which may not be stoppeddavidxu2005-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.
* Add a sysctl to force a process to sigexit if a trap signal isdavidxu2005-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.
* Cleanup sigqueue sysctl.davidxu2005-12-091-6/+2
|
* Fix a lock leak in childproc_continued().davidxu2005-12-061-1/+3
|
* set signal queue values for sysconf().davidxu2005-12-011-0/+4
|
* Make sure only remove one signal by debugger.davidxu2005-11-121-1/+2
|
* WIFxxx macros requires an int type but p_xstat is short, convert itdavidxu2005-11-091-2/+3
| | | | | | to int before using the macros. Bug reported by : Pyun YongHyeon pyunyh at gmail dot com
* Add support for queueing SIGCHLD same as other UNIX systems did.davidxu2005-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)
* Fix name compatible problem with POSIX standard. the sigval_ptr anddavidxu2005-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.
* Cleanup some signal interfaces. Now the tdsignal function acceptsdavidxu2005-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.
* Let itimer store itimerspec instead of itimerval, so I don't have todavidxu2005-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.
* 1. Make ksiginfo_alloc and ksiginfo_free public.davidxu2005-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.
* 1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, mostdavidxu2005-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
* Fix a bug relavant to debugging, a masked signal unexpectedly interruptsdavidxu2005-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>
* Oops, forgot to update this file.davidxu2005-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
* Suspend all other threads in the process while generating a core dump.das2005-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.
* The td_waitset is pointing to a stack address when thread is waitingdavidxu2005-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.
* In kern_sigtimedwait, remove waitset bits for td_sigmask beforedavidxu2005-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.
* Don't restart a timeout wait in kern_sigtimedwait, also allow itdavidxu2005-02-191-11/+27
| | | | to wait longer than a single integer can represent.
* Backout previous change (disabling of security checks for signals deliveredsobomax2005-02-131-22/+11
| | | | | | in emulation layers), since it appears to be too broad. Requested by: rwatson
OpenPOWER on IntegriCloud