4
gcc -fPIC -c getpid.c -o getpid.o
5
gcc -shared -o getpid.so getpid.o
9
FORCE_PID=1234 LD_PRELOAD=./getpid.so bash
12
# Copyright (C) 2001-2008 Kees Cook
13
# kees@outflux.net, http://outflux.net/
15
# This program is free software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either version 2
18
# of the License, or (at your option) any later version.
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write to the Free Software
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
# http://www.gnu.org/copyleft/gpl.html
32
#include <sys/types.h>
38
return atoi(getenv("FORCE_PID"));