awesome.spawn(): Return the PID
This modifies awesome.spawn() to return the process ID of the started process which could e.g. be used for matching against _NET_WM_PID. Signed-off-by: Uli Schlachter <psychon@znc.in> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
81ce9f7210
commit
ad5d160c6c
19
spawn.c
19
spawn.c
|
@ -259,20 +259,23 @@ spawn_launchee_timeout(struct ev_loop *loop, ev_timer *w, int revents)
|
|||
* g_spawn_async.
|
||||
* \return g_spawn_async value.
|
||||
*/
|
||||
static gboolean
|
||||
static GPid
|
||||
spawn_command(const gchar *command_line, GError **error)
|
||||
{
|
||||
gboolean retval;
|
||||
GPid pid;
|
||||
gchar **argv = 0;
|
||||
|
||||
if(!g_shell_parse_argv(command_line, NULL, &argv, error))
|
||||
return FALSE;
|
||||
return 0;
|
||||
|
||||
retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, error);
|
||||
NULL, NULL, &pid, error);
|
||||
g_strfreev (argv);
|
||||
|
||||
return retval;
|
||||
if (!retval)
|
||||
return 0;
|
||||
return pid;
|
||||
}
|
||||
|
||||
/** Spawn a program.
|
||||
|
@ -344,7 +347,8 @@ luaA_spawn(lua_State *L)
|
|||
}
|
||||
|
||||
GError *error = NULL;
|
||||
if(!spawn_command(cmd, &error))
|
||||
GPid pid = spawn_command(cmd, &error);
|
||||
if(!pid)
|
||||
{
|
||||
/* push error on stack */
|
||||
lua_pushstring(L, error->message);
|
||||
|
@ -354,7 +358,10 @@ luaA_spawn(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* push pid on stack */
|
||||
lua_pushnumber(L, pid);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue