summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-1/+3
| | | | | | objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-2/+2
| | | | after discussions with beck deraadt kettenis.
* It's init as a process that's special, not init's original thread.guenther2014-07-111-4/+4
| | | | | | Remember initprocess instead of initproc. ok matthew@ blambert@
* decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hderaadt2014-07-081-4/+2
| | | | | don't need to be married. ok guenther miod beck jsing kettenis
* Track whether a process is a zombie or not yet fully built via flagsguenther2014-07-041-3/+3
| | | | | | | | | | | PS_{ZOMBIE,EMBRYO} on the process instead of peeking into the process's thread data. This eliminates the need for the thread-level SDEAD state. Change kvm_getprocs() (both the sysctl() and kvm backends) to report the "most active" scheduler state for the process's threads. tweaks kettenis@ feedback and ok matthew@
* Fix wait4 to not modify status or rusage if we return 0 because ofmatthew2014-06-111-3/+9
| | | | | | | | WNOHANG, in accordance with POSIX. Additionally, if rusage is requested but the waited-on process did not terminate, return zero bytes instead of kernel stack garbage. ok deraadt, millert
* knote_processexit() needs the thread to pass down to FRELE(), so pass itguenther2014-05-151-6/+6
| | | | | | | the exiting thread instead of assuming that that's ps_mainproc. Also, panic no matter which thread of init takes it down. ok tedu@
* Move from struct proc to process the reference-count-holding pointersguenther2014-05-151-7/+11
| | | | | | | | | | to the process's vmspace and filedescs. struct proc continues to keep copies of the pointers, copying them on fork, clearing them on exit, and (for vmspace) refreshing on exec. Also, make uvm_swapout_threads() thread aware, eliminating p_swtime in kernel. particular testing by ajacoutot@ and sebastia@
* Have each thread keeps its own (counted!) reference to the process's ucredsguenther2014-04-181-1/+2
| | | | | | | | | to avoid possible use-after-free references when swapping ids in threaded processes. "Do I have the right creds?" checks are always made with the threads creds. Inspired by FreeBSD and NetBSD "right time" deraadt@
* Make sure the original thread is blocked until any other threads areguenther2014-04-171-5/+4
| | | | | | | | completely detached from the process before letting it exit, so that sleeping in systrace_exit() doesn't reorder them and lead to a panic. Panic reported by Fabian Raetz (fabian.raetz (at) gmail.com) ok tedu@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-4/+3
| | | | | | | | | struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
* Move p_emul and p_sigcode from proc to process.guenther2014-03-261-4/+4
| | | | | | | | | Tweak the handling of ktrace EMUL when changing ktracing: only generate one per process (not one per thread) and pass the correct proc pointer down to the VFS layer. Permit generating of NAMI and CSW records inside ktrace(2) itself. ok deraadt@ millert@
* Move p_sigacts from struct proc to struct process.guenther2014-03-221-8/+7
| | | | testing help mpi@
* Eliminate the exit sig handling, which was only invokable via theguenther2014-02-121-19/+4
| | | | | | | | Linux-compat clone() syscall when *not* using CLONE_THREAD. pirofti@ confirms Opera runs in compat without this, so out it goes; one less hair to choke on in kern_exit.c ok tedu@ pirofti@
* Fix the lock order reversal problem in the code that stops tracedkettenis2014-02-091-1/+3
| | | | | | | | | | | | | | | | | multi-threaded processes when they receive a signal: 1. Make the parent of the process (the tracer) wait for all threads to be stopped (in wait4(2)) instead of the thread that received the signal. This prevents us from calling tsleep(9) recursively. 2. Assume that we already hold the kernel lock if the P_SINTR flag is set (just like we already assumed we were holding the scheduler lock) and don't try to grab it again. This should fix the panic that many people reported when debugging multi-threaded programs with gdb(1). ok & lots of help from guenther@
* exit1() needs to do a final aggregation of the thread's [us]ticksguenther2014-01-241-1/+6
| | | | | | | | and runtime to the process totals. Also, add ktracing of struct rusage in wait4() and getrusage(). problem pointed out by tedu@ ok deraadt@
* Setting p->p_p to NULL when it's still running isn't safe for statclock().guenther2014-01-211-2/+1
| | | | | | It was just for cleanliness, so be a little dirty ok krw@, who managed to convince his clock to fire in the gap
* Threads can't be zombies, only processes, so change zombproc to zombprocess,guenther2014-01-201-78/+103
| | | | | | | | make it a list of processes, and change P_NOZOMBIE and P_STOPPED from thread flags to process flags. Add allprocess list for the code that just wants to see processes. ok tedu@
* Move p_textvp from struct proc to struct process so that the exit codeguenther2014-01-201-9/+9
| | | | | | can be further simplified. ok kettenis@
* Move the declarations for dogetrusage(), itimerround(), and dowait4()guenther2013-10-251-35/+19
| | | | | | | | | | to sys/*.h headers so that the compat/linux code can use them. Change dowait4() to not copyout() the status value, but rather leave that for its caller, as compat/linux has to translate it, with the side benefit of simplifying the native code. Originally written months ago as part of the time_t work; long memory, prodding, and ok from pirofti@
* Fix delivery of SIGPROF and SIGVTALRM to threaded processes by havingguenther2013-10-081-3/+1
| | | | | | | | hardclock() set a flag on the running thread and force AST processing, and then have the thread signal itself from userret(). idea and flag names from FreeBSD ok jsing@
* Snapshots for all archs have been built, so remove the T32 codeguenther2013-09-141-26/+1
|
* Switch time_t, ino_t, clock_t, and struct kevent's ident and dataguenther2013-08-131-23/+64
| | | | | | | | | | | | | | | | | | | | members to 64bit types. Assign new syscall numbers for (almost all) the syscalls that involve the affected types, including anything with time_t, timeval, itimerval, timespec, rusage, dirent, stat, or kevent arguments. Add a d_off member to struct dirent and replace getdirentries() with getdents(), thus immensely simplifying and accelerating telldir/seekdir. Build perl with -DBIG_TIME. Bump the major on every single base library: the compat bits included here are only good enough to make the transition; the T32 compat option will be burned as soon as we've reached the new world are are happy with the snapshots for all architectures. DANGER: ABI incompatibility. Updating to this kernel requires extra work or you won't be able to login: install a snapshot instead. Much assistance in fixing userland issues from deraadt@ and tedu@ and build assistance from todd@ and otto@
* factor out pid allocation to functions. add a small cache of recentlytedu2013-06-051-1/+2
| | | | | exited pids that won't get recycled. ok deraadt
* some small style changes that are distracting me from seeing a real bugtedu2013-06-011-12/+11
|
* Merge from FreeBSD, r191313guenther2013-05-071-5/+5
| | | | | | | | | | | | | | | --------------------------- On the exit of the child process which parent either set SA_NOCLDWAIT or ignored SIGCHLD, unconditionally wake up the parent instead of doing this only when the child is a last child. This brings us in line with other U**xes that support SA_NOCLDWAIT. If the parent called waitpid(childpid), then exit of the child should wake up the parent immediately instead of forcing it to wait for all children to exit. --------------------------- ok tedu@, millert@
* rthreads are always enabled. remove the sysctl.tedu2013-04-061-4/+1
| | | | ok deraadt guenther kettenis matthew
* vrele() is a tricky beast. it can sleep if the refcount hits zero,tedu2013-03-301-5/+10
| | | | | | leaving us with a free type function that isn't atomic. deal with this by erasing any reachable pointers to the vnode first, then free it. ok deraadt guenther
* do not include machine/cpu.h from a .c file; it is the responsibility ofderaadt2013-03-281-2/+1
| | | | | .h files to pull it in, if needed ok tedu
* Plug a race where we're trying to kill a traced process while it is aleadykettenis2012-09-081-4/+5
| | | | | | | | exiting. At that point ps_single may point to a proc that's already freed. Since there is no point in killing a process that's already exiting, just skip this step. ok guenther@
* Apply profiling to all threads instead of just the thread that calledguenther2012-08-021-3/+3
| | | | | | | profil() by moving P_PROFIL from proc->p_flag to process->ps_flags with matching adjustment in fork1() and exit1() ok matthew@
* exit1(EXIT_THREAD) needs to call single_thread_check() so that itguenther2012-07-111-1/+3
| | | | | | | | can be suspended and/or decrement pr->ps_singlecount if necessary. With that added, the call the other direction needs to use its own flag (EXIT_THREAD_NOCHECK) to avoid looping. problem diagnosed from a hang naddy@ hit; ok kettenis@
* The linux emulation exit hook needs to be able to sleep, so call itguenther2012-07-091-7/+8
| | | | | | before changing p_stat to SDEAD ok pirofti@
* If single threading is active, drirect the SIGKILL signal we send to orphanedkettenis2012-04-141-2/+11
| | | | | | | traced processes to the active thread, otherwise we will deadlock resulting in an unkillable stopped process. ok guenther@
* Backout a tiny part of the previous commit. Decrementing ps_singlecount inkettenis2012-04-131-5/+1
| | | | | | exit1() is wrong, since single_thread_check() already decrements it and may call exit1() after that. I can't reproduce the hang that this was supposed to fix anyway.
* First stab at making ptrace(2) usable for debugging multi-threaded programs.kettenis2012-04-131-1/+20
| | | | | | | | | | It implements a full-stop model where all threads are stopped before handing over control to the debugger. Events are reported as before through wait(2); you will have to call ptrace(PT_GET_PROCESS_STATE, ...) to find out which thread hit the event. Since this changes the size of struct ptrace_state, you will have to recompile gdb. ok guenther@
* Move the P_WAITED flag from struct proc to struct process.kettenis2012-04-111-3/+4
| | | | ok guenther@
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-101-7/+9
| | | | | | | | count processes instead of threads. New sysctl()s KERN_NTHREADS and KERN_MAXTHREAD count and limit threads. The nprocs and maxproc kernel variables are replaced by nprocess, maxprocess, nthreads, and maxthread. ok tedu@ mikeb@
* ruadd() does the summing of system and user times, so doing so againguenther2012-04-061-5/+1
| | | | | | results in bogus total times, as reported by numerous ports people. ok miod@
* Make rusage totals, itimers, and profile settings per-process insteadguenther2012-03-231-18/+36
| | | | | | | of per-rthread. Handling of per-thread tick and runtime counters inspired by how FreeBSD does it. ok kettenis@
* Add PS_EXITING to better differentiate between the process exiting andguenther2012-03-101-1/+2
| | | | the main thread exiting. c.f. regress/sys/kern/main-thread-exited/
* First steps for making ptrace work with rthreads:guenther2012-02-201-12/+14
| | | | | | | | | | - move the P_TRACED and P_INEXEC flags, and p_oppid, p_ptmask, and p_ptstat member from struct proc to struct process - sort the PT_* requests into those that take a PID vs those that can also take a TID - stub in PT_GET_THREAD_FIRST and PT_GET_THREAD_NEXT ok kettenis@
* Reimplement mutexes, condvars, and rwlocks to eliminate bugs,guenther2012-01-171-3/+3
| | | | | | | | | | | | | particularly the "consume the signal you just sent" hang, and putting the wait queues in userspace. Do cancellation handling in pthread_cond_*wait(), pthread_join(), and sem_wait(). Add __ prefix to thr{sleep,wakeup,exit,sigdivert}() syscalls; add 'abort" argument to thrsleep to close cancellation race; make thr{sleep,wakeup} return errno values via *retval to avoid touching userspace errno.
* Handle rthreads consistently in ktrace by moving the flags and vnode intoguenther2011-12-141-8/+6
| | | | | | | | struct process; KTRFAC_ACTIVE becomes P_INKTR. Also, save the credentials used to open the file in sys_ktrace() and use them for all writes to the vnode. much feedback and ok jsing@
* Suspend other rthreads before dumping core or execing; make them exitguenther2011-12-111-36/+25
| | | | | | when exec succeeds. ok jsing@
* sys_wait4 properly returns int. ok deraadttedu2011-07-251-2/+2
|
* Clean up after P_BIGLOCK removal.art2011-07-061-4/+4
| | | | | | | KERNEL_PROC_LOCK -> KERNEL_LOCK KERNEL_PROC_UNLOCK -> KERNEL_UNLOCK oga@ ok
* Recommit the reverted sigacts change now that the NFS use-after-freeguenther2011-07-051-4/+4
| | | | | | | | problem has been tracked down. This fixes the sharing of the signal handling state: shared bits go in sigacts, per-rthread bits goes in struct proc. ok deraadt@
* Revert the sigacts diff: NFS can apparently retain pointers to processesguenther2011-04-181-4/+4
| | | | | | until they're zombies and then send them signals (for intr mounts). Until that is untangled, the sigacts change is unsafe. sthen@ was the victim for this one