Commit 1d3b463e authored by Vincent Pelletier's avatar Vincent Pelletier

Do not use FILE *.

We may be called very early during runtime initialisation, so it does not
seem wise to rely on libc-initialised structures. Instead, only rely on
kernel-provided file descriptors.
parent e42b7314
...@@ -50,7 +50,7 @@ static inline void *dlsym_or_abort(const char *name) { ...@@ -50,7 +50,7 @@ static inline void *dlsym_or_abort(const char *name) {
dlerror(); /* Clear any previous error */ dlerror(); /* Clear any previous error */
symbol = dlsym(RTLD_NEXT, name); symbol = dlsym(RTLD_NEXT, name);
if (!symbol && (error = dlerror())) { if (!symbol && (error = dlerror())) {
fprintf(stderr, "Error loading '%s': %s\n", name, error); dprintf(STDERR_FILENO, "Error loading '%s': %s\n", name, error);
abort(); abort();
} }
return symbol; return symbol;
...@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) { ...@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
int ret = -1; int ret = -1;
if (argc <= 1) if (argc <= 1)
fprintf(stderr, "usage: userhosts <command> [<args>]\n"); dprintf(STDERR_FILENO, "usage: userhosts <command> [<args>]\n");
else { else {
/* In order not to depend on /proc, getauxval(AT_EXECFN) from <sys/auxv.h> /* In order not to depend on /proc, getauxval(AT_EXECFN) from <sys/auxv.h>
* should be used. However, this requires glibc >= 2.16. */ * should be used. However, this requires glibc >= 2.16. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment