]>
git.saurik.com Git - apple/xnu.git/blob - libsyscall/wrappers/libproc/libproc.h
2 * Copyright (c) 2006, 2007, 2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/cdefs.h>
27 #include <sys/param.h>
28 #include <sys/types.h>
30 #include <sys/mount.h>
31 #include <sys/resource.h>
35 #include <sys/proc_info.h>
37 #include <Availability.h>
40 * This header file contains private interfaces to obtain process information.
41 * These interfaces are subject to change in future releases.
45 @define PROC_LISTPIDSPATH_PATH_IS_VOLUME
46 @discussion This flag indicates that all processes that hold open
47 file references on the volume associated with the specified
48 path should be returned.
50 #define PROC_LISTPIDSPATH_PATH_IS_VOLUME 1
54 @define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY
55 @discussion This flag indicates that file references that were opened
56 with the O_EVTONLY flag should be excluded from the matching
59 #define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY 2
65 @function proc_listpidspath
66 @discussion A function which will search through the current
67 processes looking for open file references which match
68 a specified path or volume.
69 @param type types of processes to be searched (see proc_listpids)
70 @param typeinfo adjunct information for type
71 @param path file or volume path
72 @param pathflags flags to control which files should be considered
73 during the process search.
74 @param buffer a C array of int-sized values to be filled with
75 process identifiers that hold an open file reference
76 matching the specified path or volume. Pass NULL to
77 obtain the minimum buffer size needed to hold the
78 currently active processes.
79 @param buffersize the size (in bytes) of the provided buffer.
80 @result the number of bytes of data returned in the provided buffer;
81 -1 if an error was encountered;
83 int proc_listpidspath(uint32_t type
,
88 int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
90 int proc_listpids(uint32_t type
, uint32_t typeinfo
, void *buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
91 int proc_listallpids(void * buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_1
);
92 int proc_listpgrppids(pid_t pgrpid
, void * buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_1
);
93 int proc_listchildpids(pid_t ppid
, void * buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_1
);
94 int proc_pidinfo(int pid
, int flavor
, uint64_t arg
, void *buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
95 int proc_pidfdinfo(int pid
, int fd
, int flavor
, void * buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
96 int proc_pidfileportinfo(int pid
, uint32_t fileport
, int flavor
, void *buffer
, int buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_3
);
97 int proc_name(int pid
, void * buffer
, uint32_t buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
98 int proc_regionfilename(int pid
, uint64_t address
, void * buffer
, uint32_t buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
99 int proc_kmsgbuf(void * buffer
, uint32_t buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
100 int proc_pidpath(int pid
, void * buffer
, uint32_t buffersize
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
101 int proc_libversion(int *major
, int * minor
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
104 * Return resource usage information for the given pid, which can be a live process or a zombie.
106 * Returns 0 on success; or -1 on failure, with errno set to indicate the specific error.
108 int proc_pid_rusage(int pid
, int flavor
, rusage_info_t
*buffer
) __OSX_AVAILABLE_STARTING(__MAC_10_9
, __IPHONE_7_0
);
111 * A process can use the following api to set its own process control
112 * state on resoure starvation. The argument can have one of the PROC_SETPC_XX values
114 #define PROC_SETPC_NONE 0
115 #define PROC_SETPC_THROTTLEMEM 1
116 #define PROC_SETPC_SUSPEND 2
117 #define PROC_SETPC_TERMINATE 3
119 int proc_setpcontrol(const int control
) __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_3_2
);
120 int proc_setpcontrol(const int control
);
122 int proc_track_dirty(pid_t pid
, uint32_t flags
);
123 int proc_set_dirty(pid_t pid
, bool dirty
);
124 int proc_get_dirty(pid_t pid
, uint32_t *flags
);
125 int proc_clear_dirty(pid_t pid
, uint32_t flags
);
127 int proc_terminate(pid_t pid
, int *sig
);
131 #endif /*_LIBPROC_H_ */