summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* Add kernel support needed for the KSE-aware libpthread:mini2002-09-161-0/+3
| | | | | | | | | | | | - Use ucontext_t's to store KSE thread state. - Synthesize state for the UTS upon each upcall, rather than saving and copying a trapframe. - Deliver signals to KSE-aware processes via upcall. - Rename kse mailbox structure fields to be more BSD-like. - Store the UTS's stack in struct proc in a stack_t. Reviewed by: bde, deischen, julian Approved by: -arch
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.julian2002-09-151-1/+8
| | | | | | | | | next step is to allow > 1 to be allocated per process. This would give multi-processor threads. (when the rest of the infrastructure is in place) While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc are diverging more than they should.. corrective action needed soon.
* Completely redo thread states.julian2002-09-111-12/+12
| | | | Reviewed by: davidxu@freebsd.org
* s/SGNL/SIG/davidxu2002-09-051-3/+3
| | | | | | | | | | s/SNGL/SINGLE/ s/SNGLE/SINGLE/ Fix abbreviation for P_STOPPED_* etc flags, in original code they were inconsistent and difficult to distinguish between them. Approved by: julian (mentor)
* In the kernel code, we have the tsleep() call with the PCATCH argument.davidxu2002-09-031-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Split out a number of mostly VFS and signal related syscalls intoiedowse2002-09-011-29/+47
| | | | | | | | | | | | a kernel-internal kern_*() version and a wrapper that is called via the syscall vector table. For paths and structure pointers, the internal version either takes a uio_seg parameter or requires the caller to copyin() the data to kernel memory as appropiate. This will permit emulation layers to use these syscalls without having to copy out translated arguments to the stack gap. Discussed on: -arch Review/suggestions: bde, jhb, peter, marcel
* move the assert to cover more casesjulian2002-08-261-1/+1
|
* Don't re-lock the sched lock if we didn't unlock it.julian2002-08-231-1/+1
| | | | | | Original error by: David Xu <bsddiy@yahoo.com> Fix by: David Xu <bsddiy@yahoo.com> Completely failed to spot it: Julian Elischer <julian@freebsd.org>
* Revert some suspension/sleep/signal code from KSE-IIIjulian2002-08-211-43/+27
| | | | | | | | | We need to rethink a bit of this and it doesn't matter if we break the KSE test program for now as long as non-KSE programs act as expected. Submitted by: David Xu <bsddiy@yahoo.com> (this guy's just asking to get hit with a commit bit..)
* Do some work on keeping better track of stopped/continued state.julian2002-08-081-0/+2
| | | | | | | I'm not sure what happenned to the original setting of the P_CONTINUED flag. it appears to have been lost in the paper shuffling... Submitted by: David Xu <bsddiy@yahoo.com>
* Try harder to "set signal flags proprly [sic] for ast()". See rev.1.154.bde2002-08-061-0/+1
|
* Slight cleanup of some comments/whitespace.julian2002-08-011-6/+23
| | | | | | | | | | | | Make idle process state more consistant. Add an assert on thread state. Clean up idleproc/mi_switch() interaction. Use a local instead of referencing curthread 7 times in a row (I've been told curthread can be expensive on some architectures) Remove some commented out code. Add a little commented out code (completion coming soon) Reviewed by: jhb@freebsd.org
* Don't need to hold schedlock specifically for stop() ans it calls wakeup()julian2002-07-301-6/+1
| | | | | | that locks it anyhow. Reviewed by: jhb@freebsd.org
* revert some of the handling of STOP signals injulian2002-07-241-8/+0
| | | | | | | issignal(). Let thread_suspend_check() actually do the suspension at the user boundary. Submitted by: David Xu <bsddiy@yahoo.com>
* Rearrange the code so that it checks whether the file is somethingtruckman2002-07-101-9/+8
| | | | | | | valid to write a core dump to before doing the preparations to actually write to the file. Call VOP_GETATTR() before dropping the initial vnode lock.
* Try clean up some of the mess that resulted from layers and layersjulian2002-07-031-57/+31
| | | | | | of p4 merges from -current as things started getting different. Corroborated by: Similar patches just mailed by BDE.
* White space commit.julian2002-07-031-10/+10
| | | | | I'm working on this file but I wanted to make the whitespece commit separatly.
* Hold the sched lock across call to forward_signal() in tdsignal() togallatin2002-07-031-1/+4
| | | | | | keep SMP systems from panic'ing when ^C'ing an app suggested by julian
* Part 1 of KSE-IIIjulian2002-06-291-167/+219
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* more caddr_t removal.alfred2002-06-291-4/+4
|
* - trapsignal() no longer needs to acquire Giant for ktrpsig().jhb2002-06-071-7/+5
| | | | - Catch up to new ktrace API.
* s/!SIGNOTEMPY/SIGISEMPTY/davidc2002-06-061-1/+1
| | | | Reviewed by: marcel, jhb, alfred
* Add POSIX.1-2001 WCONTINUED option for waitpid(2). A proc flagmike2002-06-011-0/+2
| | | | | | | | | | (P_CONTINUED) is set when a stopped process receives a SIGCONT and cleared after it has notified a parent process that has requested notification via waitpid(2) with WCONTINUED specified in its options operand. The status value can be checked with the new WIFCONTINUED() macro. Reviewed by: jake
* CURSIG() is not a macro so rename it cursig().julian2002-05-291-3/+3
| | | | Obtained from: KSE tree
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-4/+3
| | | | | | | pointer instead of a proc pointer and require the process pointed to by the second argument to be locked. We now use the thread ucred reference for the credential checks in p_can*() as a result. p_canfoo() should now no longer need Giant.
* p_cansignal() returns an errno value; at some point, the check forrwatson2002-05-141-2/+2
| | | | | | | | | | inter-process signalling ceased to preserve and return that value, instead always returning EPERM. This meant that it was possible to "probe" the pid space for processes that were not otherwise visible. This change reverts that reversion. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Remove trace_req().mini2002-05-091-14/+10
| | | | Reviewed by: alfred, jhb, peter
* expand_name fixes:alfred2002-05-081-38/+32
| | | | | | | | | | | | | | | .) don't use MAXPATHLEN + 1, fix logic to compensate. .) style(9) function parameters. .) fix line wrapping. .) remove duplicated error and string handling code. .) don't NUL terminate already NUL terminated string. .) all string length variables changed from int to size_t. .) constify variables. .) catch when corename would be truncated. .) cast pid_t and uid_t args for format string. .) add parens around return arguments. Help and suggestions from: bde
* M_ZERO the temp buffer in expand_name() otherwise if an error occursalfred2002-05-071-1/+1
| | | | | while logging we may pass a non NUL terminated string to log(9) for a %s format arg.
* Return the correct error code (ENOSYS, not EINVAL) from nosys(). Gettingbde2002-05-051-1/+1
| | | | | | | | | killed by SIGSYS for unimlemented syscalls is bad enough. Obtained from: Lite2 branch The Lite2 branch has some other interesting unmerged (?) bits in this file. They are well hidden among cosmetic regressions.
* - Reorder execve() so that it performs blocking operations before itjhb2002-05-021-2/+1
| | | | | | | | locks the process. - Defer other blocking operations such as vrele()'s until after we release locks. - execsigs() now requires the proc lock to be held when it is called rather than locking the process internally.
* Redo the sigio locking.alfred2002-05-011-4/+10
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* Avoid the user-visible effect of setting SA_NOCLDWAIT when theiedowse2002-04-271-3/+6
| | | | | | | SIGCHLD handler is SIG_IGN. This is a reimplementation of the problematic revision 1.131 of kern_exit.c. To avoid accessing process UPAGES, we set a new procsig flag when the SIGCHLD handler is SIG_IGN and use that instead.
* Lock proctree_lock instead of pgrpsess_lock.jhb2002-04-161-5/+5
|
* - Change killpg1()'s first argument to be a thread instead of a process sojhb2002-04-131-36/+22
| | | | | | | | | | | | | | | | we can use td_ucred. - In killpg1(), the proc lock is sufficient to check if p_stat is SZOMB or not. We don't need sched_lock. - Close some races in psignal(). In psignal() there is a big switch statement based on p_stat. All the different cases are assuming that the process (or thread) isn't going to change state out from under it. To ensure this is true, just lock sched_lock for the entire switch. We practically held it the entire time already anyways. This also simplifies the locking somewhat and actually results in fewer lock operations. - Allow signotify() to be called with the sched_lock held since psignal() now does that. - Use td_ucred in a couple of places.
* Moved signal handling and rescheduling from userret() to ast() so thatbde2002-04-041-3/+25
| | | | | | | | | | | they aren't in the usual path of execution for syscalls and traps. The main complication for this is that we have to set flags to control ast() everywhere that changes the signal mask. Avoid locking in userret() in most of the remaining cases. Submitted by: luoqi (first part only, long ago, reorganized by me) Reminded by: dillon
* Optimized the check for unmasked pending signals in CURSIG() using a newbde2002-04-041-8/+2
| | | | | | | | | | | inline function sigsetmasked() and a new macro SIGPENDING(). CURSIG() will soon be moved out of the normal path of execution for syscalls and traps. Then its efficiency will be less important but the new interfaces will be useful for checking for unmasked pending signals in more places. Submitted by: luoqi (long ago, in a slightly different form) Assert that sched_lock is not held in CURSIG().
* Fixed some style bugs in the removal of __P(()). The main ones werebde2002-03-241-7/+7
| | | | | | not removing tabs before "__P((", and not outdenting continuation lines to preserve non-KNF lining up of code with parentheses. Switch to KNF formatting and/or rewrap the whole prototype in some cases.
* Remove __P.alfred2002-03-191-10/+10
|
* Fix warning in !SMP case.phk2002-02-261-0/+2
| | | | Submitted by: Maxime Henrion <mux@mu.org>
* Lock struct pgrp, session and sigio.tanimura2002-02-231-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Fixed a typo in rev.1.65 that gave a reference to a nonexistent variable.bde2002-02-151-1/+1
| | | | This was not detected by LINT because LINT is missing COMPAT_SUNOS.
* In a threaded world, differnt priorirites become properties ofjulian2002-02-111-4/+3
| | | | | | different entities. Make it so. Reviewed by: jhb@freebsd.org (john baldwin)
* Add a comment indicating that VOP_GETATTR() is called without appropriaterwatson2002-02-101-0/+2
| | | | locking in the core dump code. This should be fixed.
* Pre-KSE/M3 commit.julian2002-02-071-2/+2
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* o Revert kern_sig.c#1.143, as cr_cansignal() doesn't currently permitrwatson2002-01-101-3/+14
| | | | | | | a number of desirable cases in which SIGIO/SIGURG are delivered. We'll keep tweaking. Reported by: Alexander Kabaev <ak03@gte.com>
* - Teach SIGIO code to use cr_cansignal() instead of a custom CANSIGIO()rwatson2002-01-061-13/+3
| | | | | | | | | | | | | | | | | | | macro. As a result, mandatory signal delivery policies will be applied consistently across the kernel. - Note that this subtly changes the protection semantics, and we should watch out for any resulting breakage. Previously, delivery of SIGIO in this circumstance was limited to situations where the subject was privileged, or where one of the subject's (ruid, euid) matched one of the object's (ruid, euid). In the new scenario, subject (ruid, euid) are matched against the object's (ruid, svuid), and the object uid's must be a subset of the subject uid's. Likewise, jail now affects delivery, and special handling for P_SUGID of the object is present. This change can always be reversed or tweaked if it proves to disrupt application behavior substantially. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Change the preemption code for software interrupt thread schedules andjhb2002-01-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mutex releases to not require flags for the cases when preemption is not allowed: The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent switching to a higher priority thread on mutex releease and swi schedule, respectively when that switch is not safe. Now that the critical section API maintains a per-thread nesting count, the kernel can easily check whether or not it should switch without relying on flags from the programmer. This fixes a few bugs in that all current callers of swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from fast interrupt handlers and the swi_sched of softclock needed this flag. Note that to ensure that swi_sched()'s in clock and fast interrupt handlers do not switch, these handlers have to be explicitly wrapped in critical_enter/exit pairs. Presently, just wrapping the handlers is sufficient, but in the future with the fully preemptive kernel, the interrupt must be EOI'd before critical_exit() is called. (critical_exit() can switch due to a deferred preemption in a fully preemptive kernel.) I've tested the changes to the interrupt code on i386 and alpha. I have not tested ia64, but the interrupt code is almost identical to the alpha code, so I expect it will work fine. PowerPC and ARM do not yet have interrupt code in the tree so they shouldn't be broken. Sparc64 is broken, but that's been ok'd by jake and tmm who will be fixing the interrupt code for sparc64 shortly. Reviewed by: peter Tested on: i386, alpha
* o Wording fix in comment.rwatson2001-12-141-1/+1
| | | | Submitted by: tanimura via p4
* _SIG_MAXSIG (128) is the highest legal signal. The arrays are offsetpeter2001-11-031-2/+2
| | | | | | by one - see _SIG_IDX(). Revert part of my mis-correction in kern_sig.c (but signal 0 still has to be allowed) and fix _SIG_VALID() (it was rejecting ignal 128).
OpenPOWER on IntegriCloud