From 45869513bfebba80cc2ab42e4218f68b34b1e6ac Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sun, 1 Nov 2020 01:09:51 +0100 Subject: Embracing branches --- OpenFilesScreen.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenFilesScreen.c') diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index 829fafee..cd309648 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -69,10 +69,11 @@ static const char* getDataForType(const OpenFiles_Data* data, char type) { OpenFilesScreen* OpenFilesScreen_new(const Process* process) { OpenFilesScreen* this = xMalloc(sizeof(OpenFilesScreen)); Object_setClass(this, Class(OpenFilesScreen)); - if (Process_isThread(process)) + if (Process_isThread(process)) { this->pid = process->tgid; - else + } else { this->pid = process->pid; + } return (OpenFilesScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 3, " FD TYPE MODE DEVICE SIZE NODE NAME"); } @@ -106,8 +107,10 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { dup2(fdpair[1], STDOUT_FILENO); close(fdpair[1]); int fdnull = open("/dev/null", O_WRONLY); - if (fdnull < 0) + if (fdnull < 0) { exit(1); + } + dup2(fdnull, STDERR_FILENO); close(fdnull); char buffer[32] = {0}; @@ -182,10 +185,11 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) { return pdata; } - if (!WIFEXITED(wstatus)) + if (!WIFEXITED(wstatus)) { pdata->error = 1; - else + } else { pdata->error = WEXITSTATUS(wstatus); + } return pdata; } -- cgit v1.2.3