libc.obj: fix strtok && update change path to exit code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user