summaryrefslogtreecommitdiff
path: root/Source/Kernel/TaskManager
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-24 18:24:46 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-24 18:24:46 +0200
commitb639b99b3e8f4cf77560d8d473b13d992ac8eb10 (patch)
tree63ebeec75f4ab71d73d743afca04a98636dee165 /Source/Kernel/TaskManager
parentf62cfdc8ff6297616d68f6b195db7abc82ab457b (diff)
downloadMelon-b639b99b3e8f4cf77560d8d473b13d992ac8eb10.tar.gz
Melon-b639b99b3e8f4cf77560d8d473b13d992ac8eb10.zip
More work on userland syscalls : Files are implemented.
TextFile now is a common (= kernel and userland) library.
Diffstat (limited to 'Source/Kernel/TaskManager')
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp42
-rw-r--r--Source/Kernel/TaskManager/Process.class.h4
2 files changed, 26 insertions, 20 deletions
diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp
index 5859f86..a7e7d7c 100644
--- a/Source/Kernel/TaskManager/Process.class.cpp
+++ b/Source/Kernel/TaskManager/Process.class.cpp
@@ -6,6 +6,8 @@
#include <Process.iface.h>
#include <UserManager/Usr.ns.h>
+#define ISPARENT Task::currProcess()->getPid() == m_ppid
+
namespace Mem {
extern Heap kheap;
}
@@ -16,7 +18,8 @@ call_t Process::m_callTable[] = {
CALL1(PRIF_FREEPAGE, &Process::freePageSC),
CALL0(PRIF_GETPID, &Process::getPid),
CALL0(PRIF_GETPPID, &Process::getPpid),
- CALL0(PRIF_GETCMDLINE, &Process::getCmdlineSC),
+ CALL0(PRIF_ARGC, &Process::argcSC),
+ CALL1(PRIF_ARGV, &Process::argvSC),
CALL0(0, 0)
};
@@ -100,16 +103,20 @@ void Process::start() {
if (m_state == P_STARTING) m_state = P_RUNNING;
}
+void Process::pushArg(const String& arg) {
+ m_arguments.push(arg);
+}
+
void Process::exit() {
for (u32int i = 0; i < m_threads.size(); i++) {
delete m_threads[i];
}
m_threads.clear();
- for (SimpleList<File*> *iter = m_fileDescriptors; iter != 0; iter = iter->next()) {
- iter->v()->close(false);
- delete iter->v();
+ while (m_fileDescriptors != 0) {
+ m_fileDescriptors->v()->close(false);
+ delete m_fileDescriptors->v();
+ m_fileDescriptors = m_fileDescriptors->delThis();
}
- if (m_fileDescriptors != 0) delete m_fileDescriptors; //Will recursively delete whole list
m_state = P_FINISHED;
}
@@ -177,20 +184,17 @@ u32int Process::allocPageSC(u32int pos) {
return 0;
}
-u32int Process::getCmdlineSC() {
- if (Usr::uid() == m_uid or ISROOT) {
- String cmdline;
- for (u32int i = 0; i < m_arguments.size(); i++) {
- if (i != 0) cmdline += " ";
- if (m_arguments[i].contains(" ")) {
- cmdline += "'";
- cmdline += m_arguments[i];
- cmdline += "'";
- } else {
- cmdline += m_arguments[i];
- }
- }
- return cmdline.serialize();
+u32int Process::argcSC() {
+ if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
+ return (m_arguments.size());
+ }
+ return (u32int) - 1;
+}
+
+u32int Process::argvSC(u32int idx) {
+ if (idx >= m_arguments.size()) return (u32int) - 1;
+ if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
+ return m_arguments[idx].serialize();
}
return (u32int) - 1;
}
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index d0556e5..ec5a90d 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -53,7 +53,8 @@ class Process : public Ressource {
//System calls
static call_t m_callTable[];
u32int exitSC();
- u32int getCmdlineSC();
+ u32int argcSC();
+ u32int argvSC(u32int);
u32int allocPageSC(u32int);
u32int freePageSC(u32int);
bool accessible();
@@ -69,6 +70,7 @@ class Process : public Ressource {
Heap& heap() { return *m_userHeap; }
void start(); //Starts thread execution - sets m_state to P_RUNNING if == P_STARTING
+ void pushArg(const String& arg);
void exit(); //Exits properly process by killing all threads and deleting file descriptors
void registerThread(Thread* t); //Called when a thread starts
void threadFinishes(Thread* thread, u32int retval); //Called when a thread finishes