diff options
| -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; |
