Skip to content
Snippets Groups Projects
Commit 4aa2675e authored by Glauber Costa's avatar Glauber Costa Committed by Pekka Enberg
Browse files

libc: Add program_invocation_name variables

 
Redis relies on the variables being present and correctly set.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent cb2c236e
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <osv/run.hh> #include <osv/run.hh>
#include <osv/debug.hh> #include <osv/debug.hh>
#include <errno.h>
#include <libgen.h>
extern int optind; extern int optind;
...@@ -27,6 +29,11 @@ std::shared_ptr<elf::object> run(std::string path, ...@@ -27,6 +29,11 @@ std::shared_ptr<elf::object> run(std::string path,
if (!main) { if (!main) {
return nullptr; return nullptr;
} }
char *c_path = (char *)(path.c_str());
// path is guaranteed to keep existing this function
program_invocation_name = c_path;
program_invocation_short_name = basename(c_path);
// make sure to have a fresh optind across calls // make sure to have a fresh optind across calls
// FIXME: fails if run() is executed in parallel // FIXME: fails if run() is executed in parallel
int old_optind = optind; int old_optind = optind;
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
#include <osv/clock.hh> #include <osv/clock.hh>
#include <osv/mempool.hh> #include <osv/mempool.hh>
// FIXME: If we ever support multiple different executables we will have to maybe put those
// on a shared library
char *program_invocation_name;
char *program_invocation_short_name;
int libc_error(int err) int libc_error(int err)
{ {
errno = err; errno = err;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment