From d1ac6fb03e3110e35023f60f643f0c4d02c3d8b6 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sat, 24 Oct 2009 22:58:28 +0200 Subject: More work on syscalls : userland applications can run other apps. --- Source/Applications/Shell/Shell-fs.ns.cpp | 21 +++++++++++++++++++++ Source/Applications/Shell/Shell.ns.cpp | 5 +++-- Source/Applications/Shell/Shell.ns.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'Source/Applications') diff --git a/Source/Applications/Shell/Shell-fs.ns.cpp b/Source/Applications/Shell/Shell-fs.ns.cpp index 1d52836..cd9de8a 100644 --- a/Source/Applications/Shell/Shell-fs.ns.cpp +++ b/Source/Applications/Shell/Shell-fs.ns.cpp @@ -1,5 +1,6 @@ #include "Shell.ns.h" #include +#include namespace Shell { @@ -112,4 +113,24 @@ void wf(Vector& args) { } } +void run(Vector& args) { + if (args.size() == 1) { + outvt << "Nothing to run...\n"; + } else { + Process p = Process::run(args[1]); + if (p.valid()) { + p.setInVT(invt); + p.setOutVT(outvt); + for (u32int i = 2; i < args.size(); i++) { + p.pushArg(args[i]); + } + p.start(); + s32int v = p.wait(); + outvt << "Return value : " << (s64int)v << "\n"; + } else { + outvt << "Error while launching process.\n"; + } + } +} + } diff --git a/Source/Applications/Shell/Shell.ns.cpp b/Source/Applications/Shell/Shell.ns.cpp index 7213094..cd091d5 100644 --- a/Source/Applications/Shell/Shell.ns.cpp +++ b/Source/Applications/Shell/Shell.ns.cpp @@ -16,8 +16,9 @@ u32int run() { {"pwd", pwd}, {"rm", rm}, {"mkdir", mkdir}, - {"cat", cat}, - {"wf", wf}, + {"cat", cat}, + {"wf", wf}, + {"run", run}, {"", 0} }; diff --git a/Source/Applications/Shell/Shell.ns.h b/Source/Applications/Shell/Shell.ns.h index a22c18d..b2dd587 100644 --- a/Source/Applications/Shell/Shell.ns.h +++ b/Source/Applications/Shell/Shell.ns.h @@ -14,4 +14,5 @@ namespace Shell { extern void mkdir(Vector& args); extern void cat(Vector& args); extern void wf(Vector& args); + extern void run(Vector& args); } -- cgit v1.2.3