-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement enough process handling logic to make psyq4.0 happy (#46)
* Implement enough process handling logic to make psyq4.0 happy * revert gitignore * data type update * PR review * DEBUG_LOG mistake --------- Co-authored-by: ConorBobbleHat <c.github@firstpartners.net>
- Loading branch information
1 parent
ceb13b3
commit 218b4d7
Showing
8 changed files
with
167 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ build/ | |
.vscode/ | ||
# CLion | ||
.idea/ | ||
cmake-build-*/ | ||
cmake-build-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ namespace handles { | |
TYPE_UNUSED, | ||
TYPE_FILE, | ||
TYPE_MAPPED, | ||
TYPE_PROCESS | ||
}; | ||
|
||
struct Data { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "processes.h" | ||
#include "handles.h" | ||
#include <cassert> | ||
#include <cstdio> | ||
|
||
namespace processes { | ||
void *allocProcessHandle(pid_t pid) { | ||
auto* process = new Process; | ||
process->pid = pid; | ||
process->exitCode = 0; | ||
|
||
return handles::allocDataHandle(handles::Data{handles::TYPE_PROCESS, (void*)process, 0}); | ||
} | ||
|
||
Process* processFromHandle(void *handle, bool pop) { | ||
handles::Data data = handles::dataFromHandle(handle, pop); | ||
if (data.type == handles::TYPE_PROCESS) { | ||
return (Process*)data.ptr; | ||
} else { | ||
printf("Invalid file handle %p\n", handle); | ||
assert(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <cstdint> | ||
#include <sched.h> | ||
|
||
namespace processes { | ||
struct Process { | ||
pid_t pid; | ||
uint32_t exitCode; | ||
}; | ||
|
||
void *allocProcessHandle(pid_t pid); | ||
Process* processFromHandle(void* hHandle, bool pop); | ||
} |