libc.obj: fix strtok && update change path to exit code
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 1m33s
Build system / Build (pull_request) Successful in 10m23s

This commit is contained in:
2026-02-20 18:16:15 +05:00
parent 89e26439d5
commit 2a5f192267
9 changed files with 67 additions and 70 deletions

View File

@@ -2,13 +2,13 @@
#define __STDLIB_EXIT_H__
#include <stdio.h>
#include <sys/dir.h>
#include <sys/ksys.h>
#define __PATH_TO_STATUS_FILE "/tmp0/1/"
#define __PATH_TO_STATUS_FILE "/tmp0/1/.libc"
#define __STATUS_FILE_EXTENSION ".status"
#define __STATUS_FILE_FORMAT "%d"
#define __FULL_STATUS_FILE_NAME __PATH_TO_STATUS_FILE "%d" __STATUS_FILE_EXTENSION
#define __FULL_STATUS_FILE_NAME __PATH_TO_STATUS_FILE "/%d" __STATUS_FILE_EXTENSION
#define __FULL_STATUS_FILE_NAME_SIZE (sizeof(__PATH_TO_STATUS_FILE) + 32 + sizeof(__STATUS_FILE_EXTENSION))
void __libc_exit(int status, void (*before_exit)(int status));
@@ -16,6 +16,8 @@ void __libc_exit(int status, void (*before_exit)(int status));
// Save exit code
inline void WRITE_EXIT_CODE(int status)
{
mkdir(__PATH_TO_STATUS_FILE);
char buff[__FULL_STATUS_FILE_NAME_SIZE];
ksys_thread_t t;
@@ -35,14 +37,13 @@ inline void WRITE_EXIT_CODE(int status)
}
// Read exit code
inline int READ_EXIT_CODE(int pid, ksys_thread_t *t)
inline int READ_EXIT_CODE(int pid, ksys_thread_t* t)
{
char buff[__FULL_STATUS_FILE_NAME_SIZE];
int status = 0;
bool free_t = false;
if(!t)
{
if (!t) {
t = malloc(sizeof(ksys_thread_t));
_ksys_thread_info(t, -1);
free_t = true;
@@ -53,14 +54,12 @@ inline int READ_EXIT_CODE(int pid, ksys_thread_t *t)
if (f) {
fscanf(f, __STATUS_FILE_FORMAT, &status);
fclose(f);
}
else if(t && t->slot_state == 4) // it was stopped before it created status file
} else if (t && t->slot_state == 4) // it was stopped before it created status file
{
status = -1;
}
if(free_t)
{
if (free_t) {
free(t);
}