summaryrefslogtreecommitdiffstats
path: root/OpenFilesScreen.c
AgeCommit message (Collapse)Author
2024-04-17Use 'sb' name for local 'struct stat' buffersExplorer09
Deprecate the use of 'st' and other names. The 'sb' name is often seen in example codes in Linux man pages. (The 'statbuf' name is sometimes also used but I choose 'sb' name because it's shorter.) No code changes.
2024-04-17Use 'fp' name for local 'FILE*' variables.Explorer09
It is inappropriate to use the 'fd' name for 'FILE*' variables. POSIX file descriptiors are of type 'int' and are distinguished from ISO C stream pointers (type 'FILE*'). Rename these variables to 'fp', which is a preferred naming in POSIX. (Note that ISO C preferred the 'stream' name for the variables.) No code changes.
2023-12-29Clarify magic number for data/cols fieldsBenny Baumann
2023-12-29Fix naming convention inconsistencyBenny Baumann
2023-12-29OpenFilesScreen: Make column sizing dynamic for file size, offset and inodeнаб
Previously this limited the size to single-digit-gigabytes(!). Now it can be single-digit-petabytes before going out of alignment. Fixes: Debian#1059369
2023-12-26Update includes based on IWYUBenny Baumann
2023-12-26Fix code styleBenny Baumann
2023-08-30Introduce Row and Table classes for screens beyond top-processesNathan Scott
This commit refactors the Process and ProcessList structures such they each have a new parent - Row and Table, respectively. These new classes handle screen updates relating to anything that could be represented in tabular format, e.g. cgroups, filesystems, etc, without us having to reimplement the display logic repeatedly for each new entity.
2023-07-28Avoid VLA in OpenFiles screenBenny Baumann
2022-06-23Fix format specifier warning on 32 bitChristian Göttsche
OpenFilesScreen.c:229:65: error: format specifies type 'unsigned long long' but the argument has type '__off_t' (aka 'long') [-Werror,-Wformat] xSnprintf(fileSizeBuf, sizeof(fileSizeBuf), "%"PRIu64, st.st_size); /* st.st_size is long long on macOS, long on linux */ ~~~~~~~~ ^~~~~~~~~~
2022-05-19Use of NULL in execlp() must have a pointer cast.Explorer09
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
2022-01-11Avoid zombie processes on signal racesTobias Stoeckmann
The system curses library can handle terminal size changes with SIGWINCH without asking system calls to restart, which effectively stops system calls with -1 and EINTR. An example is ncurses on Linux systems. One of these system calls is waitpid. While waiting for the lsof child to complete, a badly timed SIGWINCH can interrupt the waitpid call, effectively never clearing the state of the child, keeping the zombie until htop exits. Proof of Concept: #include <unistd.h> int main(void) { close(1); close(2); sleep(5); return 0; } Compile this as a replacement "lsof" and put it into your path. Make sure that it's called instead of the real lsof. Press "l" to list open files and resize your terminal within the next 5 seconds. You will see that a zombie process is kept by htop when the timeout finishes.
2021-11-28Get file size using stat() for OpenFilesScreen if missing from lsofPeter VandeHaar
2021-11-28Strip prefix "0t" from OFFSET column of OpenFilesScreenPeter VandeHaar
2021-11-28Add OFFSET column to OpenFilesScreenPeter VandeHaar
2021-09-22Update license headers to explicitly say GPLv2+Daniel Lange
2021-01-11Make Infoscreens the correct heightDaniel Lange
2020-11-24Improving Command display/sortNarendran Gopalakrishnan
2020-11-02Embracing branchesBenny Baumann
2020-11-02Spacing around operatorsBenny Baumann
2020-10-18Make all required includes explicitBenny Baumann
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-16Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann
2020-10-10OpenFilesScreen updateChristian Göttsche
- Remove local types and function from header file - Reduce OpenFiles_Data to neccessary size - Print file access mode (r/w/u) - Fix memory leak on consecutive items without an intermediate file item: ==15257==ERROR: LeakSanitizer: detected memory leaks Direct leak of 120 byte(s) in 12 object(s) allocated from: #0 0x48c864 in strdup (htop/htop+0x48c864) #1 0x542f68 in xStrdup htop/XAlloc.c:71:17 #2 0x50e225 in OpenFilesScreen_getProcessData htop/OpenFilesScreen.c:112:25 #3 0x50cd17 in OpenFilesScreen_scan htop/OpenFilesScreen.c:141:35 #4 0x4fd3eb in InfoScreen_run htop/InfoScreen.c:81:35 #5 0x4d58bb in actionLsof htop/Action.c:361:4 #6 0x501766 in MainPanel_eventHandler htop/MainPanel.c:80:19 #7 0x5289fa in ScreenManager_run htop/ScreenManager.c:227:19 #8 0x4f748e in main htop/htop.c:300:4 #9 0x7ff73e0d8cc9 in __libc_start_main csu/../csu/libc-start.c:308:16 SUMMARY: AddressSanitizer: 120 byte(s) leaked in 12 allocation(s).
2020-10-07Mark Object instances constChristian Göttsche
2020-10-05Update License consistently to GPLv2 as per COPYING fileDaniel Lange
2020-09-17Check for fdopen failure in OpenFilesScreen_getProcessDataChristian Göttsche
2020-09-17Properly close pipe handles when work is doneBenny Baumann
2020-09-17Barely ever seen any 1000 digit PIDs …Benny Baumann
2020-09-03Axe automated header generation.Zev Weiss
Reasoning: - implementation was unsound -- broke down when I added a fairly basic macro definition expanding to a struct initializer in a *.c file. - made it way too easy (e.g. via otherwise totally innocuous git commands) to end up with timestamps such that it always ran MakeHeader.py but never used its output, leading to overbuild noise when running what should be a null 'make'. - but mostly: it's just an awkward way of dealing with C code.
2019-06-23Close pipe after lsofJesin
2018-03-16Use fork/exec instead of popen to run lsof (#757)wangqr
Fixes #675
2018-02-18Replace size_t with int/void* unionHisham Muhammad
I was occasionally passing negative values to size_t. Plus, this better reflects the intent of the variant argument. Reported by Coverity: https://scan8.coverity.com/reports.htm#v13253/p10402/fileInstanceId=22093891&defectInstanceId=7543346&mergedDefectId=174179&fileStart=251&fileEnd=500
2017-07-27Security review: check results of snprintf.Hisham Muhammad
Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
2016-10-01Interpret TTY_NR column on Linux,Hisham
translate dev_t to major:minor on other platforms. Closes #316.
2016-06-19Dynamically adjust the size of line readsHisham Muhammad
* Dynamically adjust the size of line reads. * Remove some more uses of fgets with arbitrary sizes. * Fix reading of lines and width of n column. Fixes #514.
2016-02-02Check for failure in allocations.Hisham
2016-01-12refactor *Screen classes, add InfoScreen superclassHisham Muhammad
2015-09-16Clean up some needless malloc casts, convert some mallocs to callocs, and ↵Michael McConville
fix some style
2015-08-19Rename String to StringUtils.David Hunt
Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>. From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001 From: David Hunt <dhunt@iolanthe.attlocal.net> Date: Sat, 11 Jul 2015 20:56:31 -0500 Subject: [PATCH 1/8] Rename String to StringUtils
2015-03-23incremental search and filter reintegrated!Hisham Muhammad
2015-03-23Move FunctionBar inside PanelHisham Muhammad
2014-04-24Let's see if this assert makes static analyzers happier.Hisham Muhammad
2014-04-22Fix display of open files.Hisham Muhammad
Cleanup the code to prevent this bug from happening again.
2014-02-27alignment improvementsHisham Muhammad
2014-01-16Fix order of calloc arguments.Hisham Muhammad
(Patch by Dawid Gajownik)
2012-12-05Changes in object model: separate class objects to store vtable. Also, nicer ↵Hisham Muhammad
UTF-8 display of big numbers.
2012-11-10search and filter for the strace and lsof screens!Hisham Muhammad
2011-12-26major header cleanupHisham Muhammad
2011-12-25Use strdup explicitlyHisham Muhammad
2011-11-18Mega-commit with features and tweaks for 1.0:Hisham Muhammad
* Performance improvements * Support for splitting CPU meters into two or four columns (thanks to Wim Heirman) * Switch from PLPA, which is now deprecated, to HWLOC. * Bring back support for native Linux sched_setaffinity, so we don't have to use HWLOC where we don't need to. * Support for typing in user names and column fields in selection panels.