Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
px: Copy hostname() from factid.
Browse files Browse the repository at this point in the history
  • Loading branch information
tongson committed Aug 7, 2018
1 parent 2eb34d4 commit 274bbc0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vendor/c/px/src/px.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ lclonetable(lua_State *L)
return 1;
}

static int
Chostname(lua_State *L)
{
char hostname[1026]; // NI_MAXHOST + 1
size_t len = 1025;
if (!gethostname(hostname, len)) {
hostname[1025] = '\0';
lua_pushstring(L, hostname);
} else {
return luaX_pusherror(L, "gethostname(2) error");
}
return 1;
}

/***
chroot(2) wrapper.
@function chroot
Expand Down Expand Up @@ -497,6 +511,7 @@ Cposix_spawn(lua_State *L)
static const
luaL_Reg syslib[] =
{
{"hostname", Chostname},
{"chroot", Cchroot},
{"fdclose", Cfdclose},
{"flopen", Cflopen},
Expand Down

0 comments on commit 274bbc0

Please sign in to comment.