Add a way for the process to request cleanup of the kernel cache of
the process arguments. New arguments length zero causes the drop of the pargs instead of allocation of useless zero-length buffer. Submitted by: Thomas Munro MFC after: 1 week Differential revision: https://reviews.freebsd.org/D16111
This commit is contained in:
parent
b0af06052c
commit
d6eff0832c
@ -1988,11 +1988,20 @@ sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS)
|
||||
|
||||
if (req->newlen > ps_arg_cache_limit - sizeof(struct pargs))
|
||||
return (ENOMEM);
|
||||
newpa = pargs_alloc(req->newlen);
|
||||
error = SYSCTL_IN(req, newpa->ar_args, req->newlen);
|
||||
if (error != 0) {
|
||||
pargs_free(newpa);
|
||||
return (error);
|
||||
|
||||
if (req->newlen == 0) {
|
||||
/*
|
||||
* Clear the argument pointer, so that we'll fetch arguments
|
||||
* with proc_getargv() until further notice.
|
||||
*/
|
||||
newpa = NULL;
|
||||
} else {
|
||||
newpa = pargs_alloc(req->newlen);
|
||||
error = SYSCTL_IN(req, newpa->ar_args, req->newlen);
|
||||
if (error != 0) {
|
||||
pargs_free(newpa);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
PROC_LOCK(p);
|
||||
pa = p->p_args;
|
||||
|
Loading…
Reference in New Issue
Block a user