1 
2 /*--------------------------------------------------------------------*/
3 /*--- Process-related libc stuff               pub_tool_libcproc.h ---*/
4 /*--------------------------------------------------------------------*/
5 
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9 
10    Copyright (C) 2000-2013 Julian Seward
11       jseward@acm.org
12 
13    This program is free software; you can redistribute it and/or
14    modify it under the terms of the GNU General Public License as
15    published by the Free Software Foundation; either version 2 of the
16    License, or (at your option) any later version.
17 
18    This program is distributed in the hope that it will be useful, but
19    WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    General Public License for more details.
22 
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26    02111-1307, USA.
27 
28    The GNU General Public License is contained in the file COPYING.
29 */
30 
31 #ifndef __PUB_TOOL_LIBCPROC_H
32 #define __PUB_TOOL_LIBCPROC_H
33 
34 #include "pub_tool_basics.h"   // VG_ macro
35 #include "pub_tool_vki.h"      // vki_rlimit
36 
37 /* ---------------------------------------------------------------------
38    Command-line and environment stuff
39    ------------------------------------------------------------------ */
40 
41 /* Client environment. */
42 extern HChar** VG_(client_envp);
43 
44 /* Looks up VG_(client_envp) */
45 extern HChar* VG_(getenv) ( const HChar* name );
46 
47 /* Path to all our library/aux files */
48 extern const HChar *VG_(libdir);
49 
50 // The name of the LD_PRELOAD-equivalent variable.  It varies across
51 // platforms.
52 extern const HChar* VG_(LD_PRELOAD_var_name);
53 
54 /* ---------------------------------------------------------------------
55    Important syscalls
56    ------------------------------------------------------------------ */
57 
58 extern Int  VG_(waitpid)( Int pid, Int *status, Int options );
59 extern Int  VG_(system) ( const HChar* cmd );
60 extern Int  VG_(fork)   ( void);
61 extern void VG_(execv)  ( const HChar* filename, HChar** argv );
62 extern Int  VG_(sysctl) ( Int *name, UInt namelen, void *oldp, SizeT *oldlenp, void *newp, SizeT newlen );
63 
64 /* ---------------------------------------------------------------------
65    Resource limits and capabilities
66    ------------------------------------------------------------------ */
67 
68 extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
69 extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim );
70 extern Int VG_(prctl) (Int option,
71                        ULong arg2, ULong arg3, ULong arg4, ULong arg5);
72 
73 /* ---------------------------------------------------------------------
74    pids, etc
75    ------------------------------------------------------------------ */
76 
77 extern Int VG_(gettid)  ( void );
78 extern Int VG_(getpid)  ( void );
79 extern Int VG_(getppid) ( void );
80 extern Int VG_(getpgrp) ( void );
81 extern Int VG_(geteuid) ( void );
82 extern Int VG_(getegid) ( void );
83 
84 /* ---------------------------------------------------------------------
85    Timing
86    ------------------------------------------------------------------ */
87 
88 // Returns the number of milliseconds passed since the progam started
89 // (roughly;  it gets initialised partway through Valgrind's initialisation
90 // steps).
91 extern UInt VG_(read_millisecond_timer) ( void );
92 extern Int  VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz);
93 
94 /* ---------------------------------------------------------------------
95    atfork
96    ------------------------------------------------------------------ */
97 
98 typedef void (*vg_atfork_t)(ThreadId);
99 extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child);
100 
101 
102 #endif   // __PUB_TOOL_LIBCPROC_H
103 
104 /*--------------------------------------------------------------------*/
105 /*--- end                                                          ---*/
106 /*--------------------------------------------------------------------*/
107