File: proctitle.c

package info (click to toggle)
lua-proctitle 0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68 kB
  • sloc: ansic: 23; makefile: 6
file content (30 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (3)
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
27
28
29
30
#include <lua.h>
#include <lauxlib.h>
#include <string.h>

static char *
find_argv0(lua_State *L)
{
    extern char *__progname;

    return __progname;
}

static int
set_proctitle(lua_State *L)
{
    const char *title = luaL_checkstring(L, 1);
    char *argv0 = find_argv0(L);

    // XXX no length check
    strcpy(argv0, title);

    return 0;
}

int
luaopen_proctitle(lua_State *L)
{
    lua_pushcfunction(L, set_proctitle);
    return 1;
}