server: Implement vm counters on FreeBSD.
Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f3478b4ec9
commit
93852599c2
|
@ -49,6 +49,6 @@ MANPAGES = \
|
|||
wineserver.fr.UTF-8.man.in \
|
||||
wineserver.man.in
|
||||
|
||||
EXTRALIBS = $(LDEXECFLAGS) $(RT_LIBS) $(INOTIFY_LIBS)
|
||||
EXTRALIBS = $(LDEXECFLAGS) $(RT_LIBS) $(INOTIFY_LIBS) $(PROCSTAT_LIBS)
|
||||
|
||||
unicode_EXTRADEFS = -DNLSDIR="\"${nlsdir}\"" -DBIN_TO_NLSDIR=\"`${MAKEDEP} -R ${bindir} ${nlsdir}`\"
|
||||
|
|
|
@ -36,6 +36,23 @@
|
|||
#endif
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_QUEUE_H
|
||||
# include <sys/queue.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SYSCTL_H
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_USER_H
|
||||
# define thread __unix_thread
|
||||
# include <sys/user.h>
|
||||
# undef thread
|
||||
#endif
|
||||
#ifdef HAVE_LIBPROCSTAT
|
||||
# include <libprocstat.h>
|
||||
#endif
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
|
@ -1550,9 +1567,9 @@ DECL_HANDLER(get_process_vm_counters)
|
|||
struct process *process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION );
|
||||
|
||||
if (!process) return;
|
||||
#ifdef linux
|
||||
if (process->unix_pid != -1)
|
||||
{
|
||||
#ifdef linux
|
||||
FILE *f;
|
||||
char proc_path[32], line[256];
|
||||
unsigned long value;
|
||||
|
@ -1579,9 +1596,28 @@ DECL_HANDLER(get_process_vm_counters)
|
|||
fclose( f );
|
||||
}
|
||||
else set_error( STATUS_ACCESS_DENIED );
|
||||
#elif defined(HAVE_LIBPROCSTAT)
|
||||
struct procstat *procstat;
|
||||
unsigned int count;
|
||||
|
||||
if ((procstat = procstat_open_sysctl()))
|
||||
{
|
||||
struct kinfo_proc *kp = procstat_getprocs( procstat, KERN_PROC_PID, process->unix_pid, &count );
|
||||
if (kp)
|
||||
{
|
||||
reply->virtual_size = kp->ki_size;
|
||||
reply->peak_virtual_size = reply->virtual_size;
|
||||
reply->working_set_size = kp->ki_rssize << PAGE_SHIFT;
|
||||
reply->peak_working_set_size = kp->ki_rusage.ru_maxrss * 1024;
|
||||
procstat_freeprocs( procstat, kp );
|
||||
}
|
||||
else set_error( STATUS_ACCESS_DENIED );
|
||||
procstat_close( procstat );
|
||||
}
|
||||
else set_error( STATUS_ACCESS_DENIED );
|
||||
#endif
|
||||
}
|
||||
else set_error( STATUS_ACCESS_DENIED );
|
||||
#endif
|
||||
release_object( process );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue