utils: add function for running program

In order to hand off the drm fd to another program we need
to be able to run that other program.

This commit adds an API for running a program with no arguments,
in the background.
This commit is contained in:
Ray Strode 2018-04-26 12:36:31 -04:00
parent 55186d76ab
commit 0faf4c82bf
2 changed files with 13 additions and 0 deletions

View file

@ -1015,4 +1015,16 @@ ply_get_device_scale (uint32_t width,
return device_scale;
}
bool
ply_run_program_in_background (const char *program)
{
pid_t pid;
int result;
char argv[2] = { program, NULL };
result = posix_spawn (&pid, program, NULL, NULL, argv, NULL);
return result == 0;
}
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */

View file

@ -127,6 +127,7 @@ int ply_get_device_scale (uint32_t width,
uint32_t height,
uint32_t width_mm,
uint32_t height_mm);
bool ply_run_program_in_background (const char *program);
#endif