diff options
Diffstat (limited to 'c_src/permdbport.c')
-rw-r--r-- | c_src/permdbport.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/c_src/permdbport.c b/c_src/permdbport.c new file mode 100644 index 0000000..4215d68 --- /dev/null +++ b/c_src/permdbport.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015, NORDUnet A/S. + * See LICENSE for licensing information. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdint.h> +#include <assert.h> +#include <err.h> +#include <sys/resource.h> +#include "permdb.h" +#include "erlport.h" + +static void +usage() +{ + errx(1, "usage: permdbport <path>"); +} + +int +main(int argc, char *argv[]) +{ + if (argc != 2) { + usage(); + } + const char *store = argv[1]; + + permdb_object *state = permdb_alloc(store); + + if (state == NULL) { + write_reply(NULL, 0, 4); + } + + portloop(state); + + struct rusage rusage; + getrusage(RUSAGE_SELF, &rusage); + fprintf(stderr, "permdbport user %ld.%d sys %ld.%d maxrss %ld M\n", rusage.ru_utime.tv_sec, (int)rusage.ru_utime.tv_usec, rusage.ru_stime.tv_sec, (int)rusage.ru_utime.tv_usec, rusage.ru_maxrss/1024); + + return 0; +} |