FreeNOS
POSIXApplication.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <FreeNOS/Config.h>
19#include <stdio.h>
20#include "POSIXApplication.h"
21#include "ApplicationLauncher.h"
22
24 : Application(argc, argv)
25{
26 setVersion(VERSION);
27}
28
32
34{
35 printf("%s", string);
36 return Success;
37}
38
39int POSIXApplication::runProgram(const char *path, const char **argv)
40{
41 ApplicationLauncher prog(path, argv);
42
43 const ApplicationLauncher::Result result = prog.exec();
44 if (result != ApplicationLauncher::Success)
45 {
46 return -1;
47 }
48 else
49 {
50 return (int) prog.getPid();
51 }
52}
Helper class to launch an external program.
Result exec()
Runs the external program.
const ProcessID getPid() const
Retrieve Process Identifier of the program.
Generic application.
Definition Application.h:39
Result
Result codes.
Definition Application.h:54
void setVersion(const String &version)
Set program version.
POSIXApplication(int argc, char **argv)
Class constructor.
int runProgram(const char *path, const char **argv)
Runs an external program.
virtual Result output(const char *string) const
Print text to output.
virtual ~POSIXApplication()
Class destructor.
C int printf(const char *format,...)
Output a formatted string to standard output.
Definition printf.cpp:22