File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 15
15
#include "../../../mm/paging/paging.h"
16
16
#include "../../../g-loader/g-loader.h"
17
17
#include "../../../g-loader/elf/elf.h"
18
+ #include "../task.h"
18
19
19
20
// #include "../../../kernel/kernel.h"
20
21
@@ -300,4 +301,38 @@ void* process_free(void* base_addr){
300
301
301
302
return 0 ;
302
303
304
+ }
305
+
306
+
307
+ int process_kill (struct process * _process ){
308
+
309
+ if (_process == 0 ){
310
+ return - ERR_INVARG ;
311
+ }
312
+
313
+ // free all data dynamically allocated by the process.
314
+ for (int allocation = 0 ;allocation < PROCESS_MAX_PROCESS_MEM_ALLOCATIONS ; allocation ++ ){
315
+ process_free (_process -> mem_allocations [allocation ]);
316
+ }
317
+
318
+ // mark pid as free to use
319
+ process_list [_process -> pid ] = 0 ;
320
+
321
+ // free the stack given to the process.
322
+ kfree (_process -> stack );
323
+
324
+ if (_process -> file_type == PROCESS_ELF_FILE ){
325
+ gloader_close_elf (_process -> elf_data );
326
+ }else if (_process -> file_type == PROCESS_BIN_FILE ){
327
+ kfree (_process -> raw_data );
328
+ }
329
+
330
+ // kill the task associated with the process.
331
+ task_kill (_process -> task );
332
+
333
+ kfree (_process );
334
+
335
+ return SUCCESS ;
336
+
337
+
303
338
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ struct process *process_new(const char *filename);
16
16
struct process * process_current ();
17
17
void * process_malloc (uint32_t size );
18
18
void * process_free (void * base_addr );
19
+ int process_kill (struct process * _process );
19
20
20
21
void process_init ();
21
22
You can’t perform that action at this time.
0 commit comments