summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
* Fill in the values for the ki_tid and ki_numthreads which have beengad2004-06-201-0/+2
| | | | | | | added to kproc_info. PR: bin/65803 (a tiny part...) Submitted by: Cyrille Lefevre
* Add a call to calcru() to update the kproc_info fields of ki_rusage.ru_utimegad2004-06-201-0/+2
| | | | | | and ki_rusage.ru_stime. This greatly improves the accuracy of those fields. Suggested by: bde
* Fill in the some new fields 'struct kinfo_proc', namely ki_childstime,gad2004-06-191-4/+22
| | | | | | | | | | | ki_childutime, and ki_emul. Also uses the timevaladd() routine to correct the calculation of ki_childtime. That will correct the value returned when ki_childtime.tv_usec > 1,000,000. This also implements a new KERN_PROC_GID option for kvm_getprocs(). (there will be a similar update to lib/libkvm/kvm_proc.c) Submitted by: Cyrille Lefevre
* Second half of the dev_t cleanup.phk2004-06-171-2/+2
| | | | | | | | | | | The big lines are: NODEV -> NULL NOUDEV -> NODEV udev_t -> dev_t udev2dev() -> findcdev() Various minor adjustments including handling of userland access to kernel space struct cdev etc.
* Nice, is a property of a process as a whole..julian2004-06-161-1/+1
| | | | | I mistakenly moved it to the ksegroup when breaking up the process structure. Put it back in the proc structure.
* Reference count struct tty.phk2004-06-091-1/+3
| | | | | | | | | | | Add two new functions: ttyref() and ttyrel(). ttymalloc() creates a struct tty with a reference count of one. when ttyrel sees the count go to zero, struct tty is freed. Hold references for open ttys and for ttys which are controlling terminal for sessions. Until drivers start using ttyrel(), this commit will make no difference.
* Fix a race in destruction of sessions.phk2004-06-091-2/+3
|
* Implement the new KERN_PROC_RGID option, and also implement thegad2004-05-221-0/+28
| | | | | | | | KERN_PROC_SESSION option which had been previously defined but never implemented. PR: bin/65803 (a very tiny piece of the PR)` Submitted by: Cyrille Lefevre
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Remove ps_argsopen check. It is was bogus in the past and was correctedpjd2004-04-011-5/+0
| | | | | | | not quite well by me - if kern.ps_argsopen was set to 0, users weren't permitted to see arguments of even own processes. But kern.ps_argsopen is going away, so just remove this check and leave security checks for p_cansee() function.
* Fix information leakage.pjd2004-03-171-1/+6
| | | | | | | | | | | | | Without this fix it is possible to cheat policies like: - sysctl security.bsd.see_other_[gu]ids=0, - mac_seeotheruids(4), - jail(2) and get full processes list with their arguments. This problem exists from revision 1.62 of kern_proc.c when it was introduced. Reviewed by: nectar, rwatson.
* Split the mlock() kernel code into two parts, mlock(), which unpackstruckman2004-02-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the syscall arguments and does the suser() permission check, and kern_mlock(), which does the resource limit checking and calls vm_map_wire(). Split munlock() in a similar way. Enable the RLIMIT_MEMLOCK checking code in kern_mlock(). Replace calls to vslock() and vsunlock() in the sysctl code with calls to kern_mlock() and kern_munlock() so that the sysctl code will obey the wired memory limits. Nuke the vslock() and vsunlock() implementations, which are no longer used. Add a member to struct sysctl_req to track the amount of memory that is wired to handle the request. Modify sysctl_wire_old_buffer() to return an error if its call to kern_mlock() fails. Only wire the minimum of the length specified in the sysctl request and the length specified in its argument list. It is recommended that sysctl handlers that use sysctl_wire_old_buffer() should specify reasonable estimates for the amount of data they want to return so that only the minimum amount of memory is wired no matter what length has been specified by the request. Modify the callers of sysctl_wire_old_buffer() to look for the error return. Modify sysctl_old_user to obey the wired buffer length and clean up its implementation. Reviewed by: bms
* Add sysctls to allow showing threads for pgrp, tty, uid, ruid,deischen2004-02-221-7/+31
| | | | and pid.
* - Update the sched api. sched_{add,rem,clock,pctcpu} now all accept a tdjeff2003-10-161-6/+3
| | | | argument rather than a kse.
* The KERN_PROC_PROC sysctl took 4 args in 5.0-REL and 5.1-REL. We need topeter2003-10-151-1/+4
| | | | | accept this for a bit longer. Requiring the new order of 3 args only was not very helpful.
* Remove support for the unused 4th component of the KERN_PROC_PROC sysctl.tjr2003-10-061-6/+0
|
* Allow the KERN_PROC_PROC sysctl to be used without the useless 4thtjr2003-09-191-6/+18
| | | | | name component, for consistency with KERN_PROC_ALL. Support for the 4-argument form will be removed some time before 5.2-R.
* kse.h is not needed for these files.davidxu2003-08-051-1/+0
|
* Correct six return statements which returned zero instead ofrobert2003-07-171-9/+10
| | | | | | | | | | an appropriate error number after a failure condition. In particular, three of the changed statements return ESRCH for a failed pfind(), and in also three places a non-zero return from p_cansee() will be passed back, Also noticed by: rwatson
* Make the system call vector name of a process accessible to userrobert2003-07-121-0/+29
| | | | | land applications by introducing the KERN_PROC_SV_NAME sysctl node, which is searchable by PID.
* Drop the proc lock around SYSCTL_OUT in the no-threads case.scottl2003-06-171-0/+2
| | | | Submitted by: truckman
* Move the *_new_altkstack() and *_dispose_altkstack() functions out of thealc2003-06-141-1/+1
| | | | | various pmap implementations into the machine-independent vm. They were all identical.
* Add support to sysctl_kern_proc to return all threads in a proc, not just thescottl2003-06-121-56/+90
| | | | | | first one. The old behaviour can be switched by specifying KERN_PROC_PROC. Submitted by: julian, tweaks and added functionality by myself
* Use __FBSDID().obrien2003-06-111-1/+3
|
* - Merge struct procsig with struct sigacts.jhb2003-05-131-3/+7
| | | | | | | | | | | | | | | | | - Move struct sigacts out of the u-area and malloc() it using the M_SUBPROC malloc bucket. - Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(), sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared(). - Remove the p_sigignore, p_sigacts, and p_sigcatch macros. - Add a mutex to struct sigacts that protects all the members of the struct. - Add sigacts locking. - Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now that sigacts is locked. - Several in-kernel functions such as psignal(), tdsignal(), trapsignal(), and thread_stopped() are now MP safe. Reviewed by: arch@ Approved by: re (rwatson)
* Initialize and destroy the struct proc mutex in the proc zone's init andjhb2003-05-011-0/+3
| | | | | | | fini routines instead of in fork() and wait(). This has the nice side benefit that the proc lock of any process on the allproc list is always valid and sched_lock doesn't have to be used to test against PRS_NEW anymore.
* Instead of recording the Unix time in a process when it starts, record thedes2003-05-011-2/+1
| | | | | | | uptime. Where necessary, convert it back to Unix time by adding boottime to it. This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process.
* Include altkstack pages in the RSS regardless of whether the processtjr2003-04-251-8/+6
| | | | is swapped out. Pointed out by jhb.
* It seems that 1 was not a magic value as I thought, but a coincidence.des2003-04-241-2/+2
| | | | | | | | Instead of applying the adjustment to processes with a start time of 1, apply it to all processes with a start time of less than 3600. None of this would be necessary if the start times were recorded in ticks instead of seconds and microseconds.
* Do a better job of calculating the RSS for swapped-out processes:tjr2003-04-241-3/+9
| | | | | | | | don't include the kernel stacks of swapped-out threads in the page count, but do include the alternate kernel stack. jhb provided some helpful comments on this. PR: 49102
* When filling out a kinfo_proc structure, if we come across a processdes2003-04-241-0/+2
| | | | | | whose p_stats->p_start has the magic value 1, replace it with boottime. Some users were apparently confused by the fact that ps(1) reported a start time in early 1970 for system processes.
* - Add a static function pgadjustjobc() to adjust the job control count forjhb2003-04-181-36/+42
| | | | | | | | | a process group. - Call pgadjustjobc() twice in fixjobc() to avoid code duplication and improve readability. - Use the proc lock to protect P_SHOULDSTOP() instead of sched_lock. - Check to see if a process is PRS_NEW with sched_lock before trying to lock its proc lock since the lock may not be constructed yet.
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-1/+1
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-3/+6
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* - Cache a reference to the credential of the thread that starts a ktrace injhb2003-03-131-1/+1
| | | | | | | | | | | struct proc as p_tracecred alongside the current cache of the vnode in p_tracep. This credential is then used for all later ktrace operations on this file rather than using the credential of the current thread at the time of each ktrace event. - Now that we have multiple ktrace-related items in struct proc that are pointers, rename p_tracep to p_tracevp to make it less ambiguous. Requested by: rwatson (1)
* - Various little style fixes.jhb2003-03-121-8/+5
| | | | | | | | | - If SYSCTL_OUT() fails in sysctl_kern_proc_args(), return the error instead of ignoring it if we have new arguments for the process. - If the new arguments for a process are too long, return ENOMEM instead of returning success but not doing the actual copy. Submitted by: bde
* - Avoid dropping the proc lock around a simple permissions check and justjhb2003-03-121-18/+16
| | | | | | | | | hold hold it across the check to avoid extra lock operations in the common case. - Copy in the new args to a temporary pargs structure before we drop the reference to the old one. Thus, if the copyin() fails, the process arguments are unchanged rather than being deleted. Also, p_args is no longer NULL during the sysctl operation.
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-2/+2
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Remove unnecessary lock assertion.hsu2003-01-041-15/+1
|
* Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/schweikh2002-12-301-1/+1
| | | | Add FreeBSD Id tag where missing.
* - Add the new sched_pctcpu() function to the sched_* api.jeff2002-11-211-1/+1
| | | | | | | | - Provide a routine in sched_4bsd to add this functionality. - Use sched_pctcpu() in kern_proc, which is the one place outside of sched_4bsd where the old pctcpu value was accessed directly. Approved by: re
* - Implement a mechanism for allowing schedulers to place scheduler dependantjeff2002-11-211-9/+3
| | | | | | | | | data in the scheduler independant structures (proc, ksegrp, kse, thread). - Implement unused stubs for this mechanism in sched_4bsd. Approved by: re Reviewed by: luigi, trb Tested on: x86, alpha
* Move thread related code from kern_proc.c to kern_thread.c.julian2002-10-241-258/+0
| | | | | | | | | | Add code to free KSEs and KSEGRPs on exit. Sort KSE prototypes in proc.h. Add the missing kse_exit() syscall. ksetest now does not leak KSEs and KSEGRPS. Submitted by: (parts) davidxu
* detect idle kse correctly.davidxu2002-10-221-1/+1
|
* Add an actual implementation of kse_wakeup()julian2002-10-201-1/+41
| | | | Submitted by: Davidxu
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsrobert2002-10-171-8/+8
| | | | for safety and consistency.
* - Add a new global mutex 'ppeers_lock' to protect the p_peers list ofjhb2002-10-151-0/+2
| | | | | | | | | | | | | | | | | | | processes forked with RFTHREAD. - Use a goto to a label for common code when exiting from fork1() in case of an error. - Move the RFTHREAD linkage setup code later in fork since the ppeers_lock cannot be locked while holding a proc lock. Handle the race of a task leader exiting and killing its peers while a peer is forking a new child. In that case, go ahead and let the peer process proceed normally as the parent is about to kill it. However, the task leader may have already gone to sleep to wait for the peers to die, so the new child process may not receive a SIGKILL from the task leader. Rather than try to destruct the new child process, just go ahead and send it a SIGKILL directly and add it to the p_peers list. This ensures that the task leader will wait until both the peer process doing the fork() and the new child process have received their KILL signals and exited. Discussed with: truckman (earlier versions)
* Round out the facilty for a 'bound' thread to loan out its KSEjulian2002-10-091-19/+14
| | | | | | | | | | | | | | | | | | | | | | | | in specific situations. The owner thread must be blocked, and the borrower can not proceed back to user space with the borrowed KSE. The borrower will return the KSE on the next context switch where teh owner wants it back. This removes a lot of possible race conditions and deadlocks. It is consceivable that the borrower should inherit the priority of the owner too. that's another discussion and would be simple to do. Also, as part of this, the "preallocatd spare thread" is attached to the thread doing a syscall rather than the KSE. This removes the need to lock the scheduler when we want to access it, as it's now "at hand". DDB now shows a lot mor info for threaded proceses though it may need some optimisation to squeeze it all back into 80 chars again. (possible JKH project) Upcalls are now "bound" threads, but "KSE Lending" now means that other completing syscalls can be completed using that KSE before the upcall finally makes it back to the UTS. (getting threads OUT OF THE KERNEL is one of the highest priorities in the KSE system.) The upcall when it happens will present all the completed syscalls to the KSE for selection.
OpenPOWER on IntegriCloud