diff options
| author | user <user@clank> | 2026-07-16 11:10:45 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-16 11:10:45 +0200 |
| commit | 2d3597c3a02f821bb364b8ecc23fc5949fca738d (patch) | |
| tree | 714cc7463eb36306f44fcfd67fcf52de0c13b3d1 /c/gbos.h | |
| parent | shell: I/O redirection (>/<) and pipes (|); rewrite shell in C (diff) | |
| download | gbos-2d3597c3a02f821bb364b8ecc23fc5949fca738d.tar.gz gbos-2d3597c3a02f821bb364b8ecc23fc5949fca738d.tar.xz gbos-2d3597c3a02f821bb364b8ecc23fc5949fca738d.zip | |
kill + ps: implement SYS_KILL (pid 1 immortal) and a ps tool
- PCB gains PROC_PROG (running program id), set by exec, inherited on fork.
- sys_kill(pid): reject pid 1 (immortal) and unknown/dead pids; mark the target
zombie, reparent its children to init, wake its parent if blocked in wait;
schedule away if a process kills itself. Reuses FindPcbByPid/ReparentToInit.
- sys_ps(slot,buf)->{pid,state,prog}; sys_progname(id) via NameTable reverse
lookup. NameTable gains sh/ps/kill.
- libc: kill/psget/progname; tools ps (pid state cmd) and kill <pid>.
- verified: ps lists sh(B)+ps(R); kill 1 refused; kill 42 fails.
Diffstat (limited to '')
| -rw-r--r-- | c/gbos.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -38,4 +38,7 @@ unsigned char wait(void); void setin(unsigned char fd); /* redirect stdin ($FF=console) */ void setout(unsigned char fd); /* redirect stdout ($FF=console) */ unsigned char lookup(const char *name); /* command name -> program id */ +unsigned char kill(unsigned char pid); /* terminate a pid (1 is immortal)*/ +unsigned char psget(unsigned char slot, unsigned char *buf); /* {pid,state,prog}*/ +void progname(unsigned char id, char *buf); /* id -> name */ #endif |
