From d905c9da4d8984f19cd74a17cebd2743d399b035 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Nov 2015 14:49:56 +0100 Subject: Reorganize source directory --- src/askfirst/CMakeLists.txt | 3 +++ src/askfirst/askfirst.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/askfirst/CMakeLists.txt create mode 100644 src/askfirst/askfirst.c (limited to 'src/askfirst') diff --git a/src/askfirst/CMakeLists.txt b/src/askfirst/CMakeLists.txt new file mode 100644 index 0000000..aa8c89a --- /dev/null +++ b/src/askfirst/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(askfirst askfirst.c) + +install(TARGETS askfirst RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/unitd) diff --git a/src/askfirst/askfirst.c b/src/askfirst/askfirst.c new file mode 100644 index 0000000..cdb5074 --- /dev/null +++ b/src/askfirst/askfirst.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Matthias Schiffer + * + * Based on "procd" by: + * Copyright (C) 2013 Felix Fietkau + * Copyright (C) 2013 John Crispin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char **argv) +{ + int c; + + printf("Please press Enter to activate this console.\n"); + do { + c = getchar(); + if (c == EOF) + return -1; + } + while (c != 0xA); + + if (argc < 2) { + printf("%s needs to be called with at least 1 parameter\n", argv[0]); + return -1; + } + + execvp(argv[1], &argv[1]); + printf("Failed to execute %s\n", argv[1]); + + return -1; +} -- cgit v1.2.3