File: realpath.c

package info (click to toggle)
dmtcp 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,496 kB
  • sloc: cpp: 33,592; ansic: 28,099; sh: 6,735; makefile: 1,950; perl: 1,690; python: 1,241; asm: 138; java: 13
file content (26 lines) | stat: -rw-r--r-- 758 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define _XOPEN_SOURCE 500
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

// POSIX.1-2008 says that NULL will cause memory to be allocated.
// In the earlier POSIX.1-2001, GNU implementations would return NULL.
// GNU libc contains two symbols:  one for each flavor.
// Hence, this test can succeed only in newer GNU libc's supporting POSIX.1-2008
// A value of _XOPEN_SOURCE of 500 should support this.
// Configure autotest first to test if this program can succeed without DMTCP.
int main() {
  int i;
  for (i = 0; i < (int)2e9; i++) {
    char *path = realpath("/etc/passwd", NULL);
    if (path == NULL)
      abort();
    else
      free(path);
    if ( i%(int)1e6 == 0 ) {
      printf(".");
      fflush(stdout);
    }
  }
  return 0;
}