Ticket #38506: libproc.h

File libproc.h, 4.7 KB (added by cooljeanius (Eric Gallager), 12 years ago)

libproc.h as it exists on Lion

Line 
1/*
2 * Copyright (c) 2006, 2007, 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23#ifndef _LIBPROC_H_
24#define _LIBPROC_H_
25
26#include <sys/cdefs.h>
27#include <sys/param.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <sys/mount.h>
31#include <stdint.h>
32
33#include <sys/proc_info.h>
34
35#include <Availability.h>
36
37/*
38 * This header file contains private interfaces to obtain process information. 
39 * These interfaces are subject to change in future releases.
40 */
41
42/*!
43        @define PROC_LISTPIDSPATH_PATH_IS_VOLUME
44        @discussion This flag indicates that all processes that hold open
45                file references on the volume associated with the specified
46                path should be returned.
47 */
48#define PROC_LISTPIDSPATH_PATH_IS_VOLUME        1
49
50
51/*!
52        @define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY
53        @discussion This flag indicates that file references that were opened
54                with the O_EVTONLY flag should be excluded from the matching
55                criteria.
56 */
57#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY       2
58
59__BEGIN_DECLS
60
61
62/*!
63        @function proc_listpidspath
64        @discussion A function which will search through the current
65                processes looking for open file references which match
66                a specified path or volume.
67        @param type types of processes to be searched (see proc_listpids)
68        @param typeinfo adjunct information for type
69        @param path file or volume path
70        @param pathflags flags to control which files should be considered
71                during the process search.
72        @param buffer a C array of int-sized values to be filled with
73                process identifiers that hold an open file reference
74                matching the specified path or volume.  Pass NULL to
75                obtain the minimum buffer size needed to hold the
76                currently active processes.
77        @param buffersize the size (in bytes) of the provided buffer.
78        @result the number of bytes of data returned in the provided buffer;
79                -1 if an error was encountered;
80 */
81int     proc_listpidspath(uint32_t      type,
82                          uint32_t      typeinfo,
83                          const char    *path,
84                          uint32_t      pathflags,
85                          void          *buffer,
86                          int           buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
87
88int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
89int proc_listallpids(void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
90int proc_listpgrppids(pid_t pgrpid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
91int proc_listchildpids(pid_t ppid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
92int proc_pidinfo(int pid, int flavor, uint64_t arg,  void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
93int proc_pidfdinfo(int pid, int fd, int flavor, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
94int proc_pidfileportinfo(int pid, uint32_t fileport, int flavor, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
95int proc_name(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
96int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
97int proc_kmsgbuf(void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
98int proc_pidpath(int pid, void * buffer, uint32_t  buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
99int proc_libversion(int *major, int * minor) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
100/*
101 * A process can use the following api to set its own process control
102 * state on resoure starvation. The argument can have one of the PROC_SETPC_XX values
103 */
104#define PROC_SETPC_NONE         0
105#define PROC_SETPC_THROTTLEMEM  1
106#define PROC_SETPC_SUSPEND      2
107#define PROC_SETPC_TERMINATE    3
108
109int proc_setpcontrol(const int control) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
110int proc_setpcontrol(const int control);
111
112__END_DECLS
113
114#endif /*_LIBPROC_H_ */