diff options
| author | _ov4 <ov4@ov4.org> | 2026-08-11 13:27:46 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-08-11 13:27:46 +0000 |
| commit | 46e4e11e1e30c1bcc05335df829a792d657ea781 (patch) | |
| tree | 16d3ec3c594d569a640ba18c84c6bb2d52c4bd7c | |
| parent | d0c40a95b3fa1a487e573161591e358ba3a87b92 (diff) | |
update
| -rw-r--r-- | tsh.cc | 10 | ||||
| -rw-r--r-- | util.h | 5 |
2 files changed, 10 insertions, 5 deletions
@@ -15,8 +15,10 @@ #include <iostream> #include <vector> #include <string> +#include "util.h" using namespace std; +using ov4::atomic_print; /* Misc manifest constants */ #define MAXLINE 1024 /* max line size */ @@ -318,17 +320,15 @@ void waitfg(pid_t pid) */ void sigchld_handler(int sig) { - constexpr int numlen = 20; int errno_backup = errno; int status, pid; - char msg[] = "sig chld, pid: ", num[numlen]; + char msg[] = "sig chld, pid: "; write(STDOUT_FILENO, msg, strlen(msg)); while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - // deletejob(NULL, pid); - sprintf(num, "%d\n", pid); - write(STDOUT_FILENO, num, strlen(num)); + deletejob(NULL, pid); + atomic_print(pid); } @@ -13,6 +13,11 @@ namespace ov4 { +void atomic_print(char *s); +void atomic_print(int x); +void reverse(char str[], int length); +char* itoa(int num, char* str, int base); + const int DECIMAL = 10; const int LENGTH = 20; |
