summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Correct the sharing of the signal handling state: stuff that shouldguenther2011-04-151-4/+4
| | | | | | | | | | | | be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves to struct sigacts, wihle stuff that should be per rthread (ps_oldmask, SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread until our locking around coredumping is better. Oh, and remove the old SunOS-compat ps_usertramp member. "I like the sound of this" tedu@
* Move PPWAIT flag from struct proc to process, so that rthreads inguenther2011-04-031-4/+6
| | | | | | | | | a vforked child behave correctly. Have the parent in a vfork() wait on a (different) flag in *its* process instead of the child to prevent a possible use-after-free. When ktracing the child return from a fork, call it rfork if an rthread was created. ok blambert@
* Fix knote handling for exiting processes: when triggering a NOTE_EXITguenther2010-08-021-3/+3
| | | | | | | | | knote, remove it from the process's klist; after handling those, remove and drop any remaining knotes from the process's klist. Ban attaching knotes to processes that have started exiting or attaching them via the pid of a thread other than the main thread. ok tedu@, deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-107/+120
| | | | | | | | | so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots
* Rollback the allproclk and fileheadlk addition. When grabbing anguenther2010-07-191-5/+1
| | | | | | | | rwlock, the thread will release biglock if it sleeps, means that atomicity from before the rw_enter() to after it is not guaranteed. The change didn't address those, so pulling it until it does. "go for it" tedu@
* We always copy struct pcred when creating a new process, so the referenceguenther2010-06-291-9/+10
| | | | | count was always one. That's pointless, so remove the member and the code. ok tedu@
* Eliminate RTHREADS kernel option in favor of a sysctl. The actual statustedu2010-06-291-5/+4
| | | | | (not done) hasn't changed, but now it's less work to test things. ok art deraadt
* Bad tedu, no cookie.oga2010-05-261-6/+6
| | | | | | | | | | Don't set SDEAD on the process in exit1 untile we have grabbed the allproclk. allproclk is a rwlock and thus we may sleep to grab hold of it. This is a big of a bugger when we just set a flag that means we panic if we sleep. ok art@. turns Tom Murphy's fstat panic into a deadlock instead *sigh*, this is being looked into.
* move knote list to struct process. ok guenthertedu2010-05-181-2/+3
|
* Add a rwlock around the filehead and allproc lists, mainly to protecttedu2010-03-241-1/+5
| | | | | list walkers in sysctl that can block. As a reward, no more vslock. With some feedback from art, guenther, phessler. ok guenther.
* When using ptrace(), death of the traced process should always sendguenther2009-12-201-2/+2
| | | | | | | | | SIGCHLD to the tracer, even if the real parent requested an alternate exit signal. So, delay clearing the P_TRACED flag from exit1() to sys_wait4() so that we don't send the wrong signal from reaper(). Originally discussed with kurt months ago "looks good" deraadt@
* svr4_sys_waitsys() was seemingly implemented by copying sys_wait4()guenther2009-12-201-22/+26
| | | | | | | | | and hacking on it. Since then, some of the details of finishing a wait have changed (p_exitsig handling), so factor out the common bit into into proc_finish_wait() and have both sys_wait4() and svr4_sys_waitsys() call that to kill the divergence. "looks good" deraadt@
* Change threxit() to take a pointer to a pid_t to zero out from theguenther2009-11-271-3/+9
| | | | | | | | | | kernel so that librthread can detect when a thread is completely done with its stack without need a kqueue. The dying thread moves itself to a GC list, other threads scan the GC list on pthread_create() and pthread_join() and free the stack and handle once the thread's thread id is zeroed. "get it in" deraadt@, tedu@, cheers by others
* Don't drop the big lock at the end of exit1(), but move it into the middle ofderaadt2009-10-051-4/+1
| | | | | | | | | sched_exit(). This means that cpu_exit() and whatever it does (for instance calling free(), as well as the deadproc p_hash handling are now locked as well. This may have been one of the causes of the reaper panics, especially with rthread patches... which were terminating a lot of threads very quickly onto the deadproc p_hash list. ok kurt kettenis miod
* Remove extra psignal/wakeup in exit1() which can cause the parent tokurt2009-06-241-6/+3
| | | | | receive SIGCHLD twice if scheduled before the reaper runs. diff by guenther@ and myself. okay guenther@ deraadt@
* Fix SEM_UNDO handling for rthreads: use the struct process* insteadguenther2009-04-031-5/+3
| | | | | | | | of the struct proc* as the identifier for SEM_UNDO tracking and only call semexit() from the original thread, once the process as a whole is exiting ok tedu@
* Remove cpu_wait(). It's original use was to be called from the reaper sooga2009-03-261-9/+1
| | | | | | | | MD code would free resources that couldn't be freed until we were no longer running in that processor. However, it's is unused on all architectures since mikeb@'s tss changes on x86 earlier in the year. ok miod@
* Move the functionality of psignal() to a new function ptsignal()guenther2008-12-161-6/+8
| | | | | | | | | | | | | that takes an additional argument "type" that indicates whether the signal is for the process, just a particular thread, or propagated to a thread because it's not caught or blocked. psignal() becomes a wrapper that does the first of those. So that sys_kill() can tell apart signals for the process and signals for the process's original thread, the tid of the original thread is defined as its pid + THREAD_PID_OFFSET. ok tedu@ art@ andreas@ kurt@ "better early than late" deraadt@
* a little bit of paranoiaderaadt2008-12-111-1/+2
|
* remove a really stupid comment. Duh, of course it can blockderaadt2008-11-061-2/+1
|
* accidental commit ... backoutderaadt2008-10-311-7/+3
|
* kern_sysctl.cderaadt2008-10-311-3/+7
|
* Use msleep() in the reaper to make it not lose events. Based on discussionderaadt2008-10-301-8/+4
| | | | | PR 5609, and revisited with dlg. Tested on all platforms. ok miod
* Back-in; problems were apparently elsewhere.guenther2008-10-141-2/+2
| | | | | | | | | Put a reference count in struct process to prevent use-after-free if the main thread reaches the reaper ahead of some other thread in the process. Use the reference count to update the user process count correctly when changin real uid. "please re-commit before something else nasty comes in" deraadt@
* backout; is causing some people difficultyderaadt2008-10-101-2/+2
|
* Put a reference count in struct process to prevent use-after-freeguenther2008-10-091-2/+2
| | | | | | | if the main thread reaches the reaper ahead of some other thread in the process. ok art@ tedu@
* set p_flag to 0 sooner, so we don't overwrite the thread flag. and correctlytedu2008-05-111-5/+3
| | | | free things when exiting a threaded proc. from philip guenther
* Make context switching much more MI:art2007-10-101-14/+4
| | | | | | | | | | | | | | | | | | | | - Move the functionality of choosing a process from cpu_switch into a much simpler function: cpu_switchto. Instead of having the locore code walk the run queues, let the MI code choose the process we want to run and only implement the context switching itself in MD code. - Let MD context switching run without worrying about spls or locks. - Instead of having the idle loop implemented with special contexts in MD code, implement one idle proc for each cpu. make the idle loop MI with MD hooks. - Change the proc lists from the old style vax queues to TAILQs. - Change the sleep queue from vax queues to TAILQs. This makes wakeup() go from O(n^2) to O(n) there will be some MD fallout, but it will be fixed shortly. There's also a few cleanups to be done after this. deraadt@, kettenis@ ok
* move p_limit and p_cred into struct processtedu2007-04-121-12/+8
| | | | | leave macros behind for now to keep the commit small ok art beck miod pedro
* remove proc from process thread list sooner in exit (notably, before waitingtedu2007-04-111-13/+5
| | | | | for the list to become empty) ok art
* undotedu2007-04-101-5/+13
|
* remove process from thread list sooner in exit (notably, before waitingtedu2007-04-101-13/+5
| | | | for the list to become empty)
* jason crawford noticed that the rthreads diff didn't compile with rthreads!tedu2007-04-051-2/+2
|
* oursleves -> ourselvespedro2007-04-041-2/+2
|
* Don't remove the process from the threads queue in proc_zap() as thatpedro2007-04-041-2/+3
| | | | currently already happens in exit1(), okay art@
* Start moving state that is shared among threads in a process intoart2007-04-031-18/+31
| | | | | | | | | | | a new struct. Instead of doing a huge rename and deal with the fallout for weeks, like other projects that need no mention, we will slowly and carefully move things out of struct proc into a new struct process. - Create struct process and the infrastructure to create and remove them. - Move threads in a process into struct process. deraadt@, tedu@ ok
* Since p_flag is often manipulated in interrupts and without biglockart2007-03-151-10/+10
| | | | | | | | | | | | it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
* consistantly count context switches on exit; miod@ okmickey2006-06-231-1/+2
|
* Nothing sets P_FSTRACE anymore, so remove all what's left of it.miod2006-06-151-8/+2
|
* release kernel lock _after_ the emulation exit hook is called to protect possible free()s; tedu@ deraadt@ okmickey2006-04-061-4/+4
|
* Compile out more rthreads stuff unless option RTHREADS;miod2006-02-201-2/+5
| | | | discussed with a few, ok tedu@
* make exiting actually work when a thread receives a signal.tedu2005-12-131-11/+5
| | | | | previously, the child and parent would deadlock in the kernel and be unable to exit. help with diagnosis from art@.
* kernel support for threaded processes (rthreads).tedu2005-12-031-4/+62
| | | | | | | | uses rfork(RFTHREAD) to create threads, which are presently processes that are a little more tightly bound together. several new syscalls added to facilitate a userland thread library. all conditional on RTHREADS, currently disabled. ok deraadt
* ansi/deregister.jsg2005-11-281-19/+9
| | | | 'go for it' deraadt@
* ptrace(2) following fork(2)kettenis2005-09-141-1/+3
| | | | ok miod@
* Use list and queue macros where applicable to make the code easier to read;miod2004-12-261-5/+5
| | | | no change in compiler assembly output.
* hardclock detects if ITIMER_VIRTUAL and ITIMER_PROF have expired andart2004-08-041-1/+3
| | | | | | | | | | | | | | | | | | | sends SIGVTALRM and SIGPROF to the process if they had. There is a big problem with calling psignal from hardclock on MULTIPROCESSOR machines though. It means we need to protect all signal state in the process with a lock because hardclock doesn't obtain KERNEL_LOCK. Trying to track down all the tentacles of this quickly becomes very messy. What saves us at the moment is that SCHED_LOCK (which is used to protect parts of the signal state, but not all) happens to be recursive and forgives small and big errors. That's about to change. So instead of trying to hunt down all the locking problems here, just make hardclock not send signals. Instead hardclock schedules a timeout that will send the signal later. There are many reasons why this works just as good as the previous code, all explained in a comment written in big, friendly letters in kern_clock. miod@ ok noone else dared to ok this, but noone screamed in agony either.
* SIMPLELOCK -> mutex for the lock around deadproc list.art2004-07-221-12/+21
| | | | | | | Also move the whole deadproc infrastructure to kern_exit, it's only used there. miod@ ok
* debranch SMP, have funniklas2004-06-131-6/+18
|
* make acct(2) optional with ACCOUNTINGtedu2004-05-271-1/+3
| | | | ok art@ deraadt@