Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
675 bytes
|
Line | |
---|
1 | #include <sys/types.h>
|
---|
2 | #include <dlfcn.h>
|
---|
3 | #include <error.h>
|
---|
4 | #include <mcheck.h>
|
---|
5 | #include <stdlib.h>
|
---|
6 | #include <unistd.h>
|
---|
7 |
|
---|
8 | pid_t pid, pid2;
|
---|
9 |
|
---|
10 | pid_t getpid(void)
|
---|
11 | {
|
---|
12 | pid_t (*f)(void);
|
---|
13 | f = (pid_t (*)(void)) dlsym (RTLD_NEXT, "getpid");
|
---|
14 | if (f == NULL)
|
---|
15 | error (EXIT_FAILURE, 0, "dlsym (RTLD_NEXT, \"getpid\"): %s", dlerror ());
|
---|
16 | return (pid2 = f()) + 26;
|
---|
17 | }
|
---|
18 |
|
---|
19 | int
|
---|
20 | main (void)
|
---|
21 | {
|
---|
22 | pid_t (*f)(void);
|
---|
23 |
|
---|
24 | mtrace ();
|
---|
25 |
|
---|
26 | f = (pid_t (*)(void)) dlsym (RTLD_DEFAULT, "getpid");
|
---|
27 | if (f == NULL)
|
---|
28 | error (EXIT_FAILURE, 0, "dlsym (RTLD_DEFAULT, \"getpid\"): %s", dlerror ());
|
---|
29 | pid = f();
|
---|
30 | if (pid != pid2 + 26)
|
---|
31 | error (EXIT_FAILURE, 0, "main getpid() not called");
|
---|
32 | return 0;
|
---|
33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.