feat(libkern): strrchr (StringFindLastOccurenceOfCharacter)
fix(OSServiceProcessSpawn): now it uses strrchr to get process name
This commit is contained in:
@@ -10,4 +10,5 @@ Int32 StringCompare(const char* firstString, const char* secondString);
|
||||
Int32 StringCompareWithLimit(const char* firstString, const char* secondString, UInt64 limit);
|
||||
char* StringCopy(char* destination, const char* source);
|
||||
char* StringCopyWithLimit(char* destination, const char* source, UInt64 limit);
|
||||
UInt64 StringGetLength(const char* string);
|
||||
UInt64 StringGetLength(const char* string);
|
||||
const char* StringFindLastOccurrenceOfCharacter(const char* string, char separator);
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <OS/Exec/OSLoader.h>
|
||||
#include <IO/IOConsole.h>
|
||||
|
||||
|
||||
#include <lib/String.h>
|
||||
|
||||
Int32 OSServiceProcessExit(Int32 code) {
|
||||
IOConsoleLog("\n[Dewar] process \"%s\" exited with code %d\n", gOSSchedulerCurrentTask->process->name, code);
|
||||
OSSchedulerTerminate();
|
||||
@@ -15,7 +18,12 @@ Int32 OSServiceProcessExit(Int32 code) {
|
||||
|
||||
|
||||
Int32 OSServiceProcessSpawn(const char* path) {
|
||||
return OSLoaderProcessSpawn(path, path);
|
||||
const char* name = StringFindLastOccurrenceOfCharacter(path, '/');
|
||||
|
||||
if (name) name++;
|
||||
else name = path;
|
||||
|
||||
return OSLoaderProcessSpawn(path, name);
|
||||
}
|
||||
|
||||
Int32 OSServiceProcessWait(UInt64 processID) {
|
||||
|
||||
@@ -74,4 +74,13 @@ UInt64 StringGetLength(const char* string) {
|
||||
UInt64 result = 0;
|
||||
for (result = 0; string[result]; result++);
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* StringFindLastOccurrenceOfCharacter(const char* string, char separator) {
|
||||
const char* lastSeparator = nullptr;
|
||||
do {
|
||||
if (*string == separator) lastSeparator = (char*)string;
|
||||
} while (*string++);
|
||||
|
||||
return lastSeparator;
|
||||
}
|
||||
Reference in New Issue
Block a user