summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2012-03-08 20:48:21 -0800
committerGeoff Levand <geoff@infradead.org>2012-03-08 20:51:37 -0800
commit604a1ccf072f9f33326fb6dc919c1b6233d40866 (patch)
tree88297738af995f9ea8df78e134d0a2dac111d157 /lib
parentae0ba68f475ae5b057aad6538765bc8702134b9a (diff)
downloadtalos-petitboot-604a1ccf072f9f33326fb6dc919c1b6233d40866.tar.gz
talos-petitboot-604a1ccf072f9f33326fb6dc919c1b6233d40866.zip
Add --start-daemon option to ui programs
Add the option --start-daemon to automatically start pb-discover if it is not already started. For use when running as a stand-alone app. Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/system/system.c6
-rw-r--r--lib/system/system.h3
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7b3d50d..6440fe4 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -12,7 +12,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-AM_CPPFLAGS = -I$(top_srcdir)/lib $(DEFAULT_CPPFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/lib $(DEFAULT_CPPFLAGS) \
+ -DPREFIX='"$(prefix)"'
AM_CFLAGS = $(DEFAULT_CFLAGS)
diff --git a/lib/system/system.c b/lib/system/system.c
index 7371445..1b506d2 100644
--- a/lib/system/system.c
+++ b/lib/system/system.c
@@ -17,6 +17,7 @@
#include "system.h"
const struct pb_system_apps pb_system_apps = {
+ .prefix = PREFIX,
.cp = "/bin/cp",
.kexec = "/sbin/kexec",
.mount = "/bin/mount",
@@ -104,7 +105,7 @@ int pb_rmdir_recursive(const char *base, const char *dir)
* @cmd_argv: An argument list array for execv.
*/
-int pb_run_cmd(const char *const *cmd_argv)
+int pb_run_cmd(const char *const *cmd_argv, int wait)
{
#if defined(DEBUG)
enum {do_debug = 1};
@@ -149,6 +150,9 @@ int pb_run_cmd(const char *const *cmd_argv)
exit(EXIT_FAILURE);
}
+ if (!wait && !waitpid(pid, &status, WNOHANG))
+ return 0;
+
if (waitpid(pid, &status, 0) == -1) {
pb_log("%s: waitpid failed: %s\n", __func__,
strerror(errno));
diff --git a/lib/system/system.h b/lib/system/system.h
index 1918309..d39280d 100644
--- a/lib/system/system.h
+++ b/lib/system/system.h
@@ -2,6 +2,7 @@
#define _PB_LIB_SYSTEM_H
struct pb_system_apps {
+ const char *prefix;
const char *cp;
const char *kexec;
const char *mount;
@@ -14,7 +15,7 @@ struct pb_system_apps {
extern const struct pb_system_apps pb_system_apps;
-int pb_run_cmd(const char *const *cmd_argv);
+int pb_run_cmd(const char *const *cmd_argv, int wait);
int pb_mkdir_recursive(const char *dir);
int pb_rmdir_recursive(const char *base, const char *dir);
OpenPOWER on IntegriCloud