Skip to content

Commit

Permalink
More waitpid changes
Browse files Browse the repository at this point in the history
  • Loading branch information
afxgroup committed Jun 14, 2024
1 parent 95db1b5 commit d4c4689
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/misc/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void free_elements(struct hashmap *map) {
if (map->elfree) {
for (size_t i = 0; i < map->nbuckets; i++) {
struct bucket *bucket = bucket_at(map, i);
if (bucket->dib) map->elfree(bucket_item(bucket));
if (bucket != NULL && bucket->dib) map->elfree(bucket_item(bucket));
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion library/shared_library/clib4.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ BPTR libClose(struct LibraryManagerInterface *Self) {
}
}
/* Remove spawnedProcess hashmap */
hashmap_free(res->spawnedProcesses);
if (res->spawnedProcesses != NULL) {
hashmap_free(res->spawnedProcesses);
res->spawnedProcesses = NULL;
}
}

--libBase->libNode.lib_OpenCnt;
Expand Down
2 changes: 1 addition & 1 deletion library/unistd/get_default_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __get_default_file(int file_descriptor, long *file_ptr) {

(*file_ptr) = (long) __resolve_fd_file(fd);

result = 0;
result = OK;

out:

Expand Down
7 changes: 6 additions & 1 deletion library/wait/waitpid.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ pid_t waitpid(pid_t pid, int *status, int options) {

struct Clib4Resource *res = (APTR) OpenResource(RESOURCE_NAME);
if (res) {
if (res->spawnedProcesses == NULL) {
*status = 0;
return 0;
}

struct Hook h = {{NULL, NULL}, (HOOKFUNC) hook_function, NULL, NULL};
int32 process;
size_t iter = 0;
Expand Down Expand Up @@ -152,7 +157,7 @@ pid_t waitpid(pid_t pid, int *status, int options) {
else {
*status = 0;
D(("Childred with pid %ld not found!\n", pid));
return item->pid;
return pid;
}
*status = 0xFF;
return 0;
Expand Down

0 comments on commit d4c4689

Please sign in to comment.