File: pttest.c

package info (click to toggle)
python-setproctitle 1.3.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 276 kB
  • sloc: ansic: 946; python: 658; makefile: 21
file content (24 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* trying to understand why in order to clobber argv
 * postgres moves around environ too.
 */
#include <stdio.h>

extern char **environ;

int
main(int argc, char **argv)
{
    char **p;
    printf("argv:       %p\n", argv);
    printf("environ:    %p\n", environ);
    for (p = argv; *p; ++p) {
        printf("argv[%i]:    %p (%s)\n", p - argv, *p, *p);
    }
    for (p = environ; *p; ++p) {
        printf("environ[%i]: %p (%s)\n", p - environ, *p, *p);
    }

    /* My conclusion is that environ is contiguous to argv */
    return 0;
}