Commit Graph

41 Commits

Author SHA1 Message Date
Narendran Gopalakrishnan 09fe94da18 Improving Command display/sort 2020-11-24 19:05:48 +01:00
Benny Baumann 45869513bf Embracing branches 2020-11-02 22:15:01 +01:00
Benny Baumann 61e14d4bb2 Spacing around operators 2020-11-02 22:15:01 +01:00
Benny Baumann 0f5262917f Make all required includes explicit
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-18 20:09:05 +02:00
Benny Baumann 872e542f4e Rename StringUtils.[ch] to XUtils.[ch] 2020-10-16 20:30:21 +02:00
Christian Göttsche f8b9ced93f OpenFilesScreen update
- 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-10 11:26:43 +02:00
Christian Göttsche ba282cfe19 Mark Object instances const 2020-10-07 13:01:53 +02:00
Daniel Lange 079c2abf8e Update License consistently to GPLv2 as per COPYING file 2020-10-05 10:13:12 +02:00
Christian Göttsche 1efddaf1e5 Check for fdopen failure in OpenFilesScreen_getProcessData 2020-09-17 21:43:53 +02:00
Benny Baumann 443a943798 Properly close pipe handles when work is done 2020-09-17 21:43:05 +02:00
Benny Baumann 6921000481 Barely ever seen any 1000 digit PIDs … 2020-09-17 21:43:05 +02:00
Zev Weiss a1a027b9bd Axe automated header generation.
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.
2020-09-03 11:58:58 -05:00
Jesin 886eb68102 Close pipe after lsof 2019-06-23 13:13:05 -04:00
wangqr a042cfece2 Use fork/exec instead of popen to run lsof (#757)
Fixes #675
2018-03-16 11:39:03 -03:00
Hisham Muhammad 8c653212c0 Replace size_t with int/void* union
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
2018-02-18 10:38:49 -03:00
Hisham Muhammad 09e241fb12 Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
2017-07-27 16:07:50 -03:00
Hisham 8af4d9f453 Interpret TTY_NR column on Linux,
translate dev_t to major:minor on other platforms.
Closes #316.
2016-10-01 03:09:04 -03:00
Hisham Muhammad 0fa03322a9 Dynamically adjust the size of line reads
* 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-06-19 18:55:35 -03:00
Hisham b54d2dde40 Check for failure in allocations. 2016-02-02 15:53:02 +01:00
Hisham Muhammad 466d4da0c6 refactor *Screen classes, add InfoScreen superclass 2016-01-12 06:00:58 -02:00
Michael McConville 445222e48c Clean up some needless malloc casts, convert some mallocs to callocs, and fix some style 2015-09-16 23:42:36 -04:00
David Hunt 5e602f18d5 Rename String to StringUtils.
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-08-19 13:45:20 -03:00
Hisham Muhammad ade7993fcb incremental search and filter reintegrated! 2015-03-23 17:04:53 -03:00
Hisham Muhammad d0c72c3fb2 Move FunctionBar inside Panel 2015-03-23 15:26:56 -03:00
Hisham Muhammad 446d86c7a2 Let's see if this assert makes static analyzers happier. 2014-04-24 12:16:51 -03:00
Hisham Muhammad 1de8762e71 Fix display of open files.
Cleanup the code to prevent this bug from happening again.
2014-04-22 18:45:47 -03:00
Hisham Muhammad 6d90e58c01 alignment improvements 2014-02-27 16:35:22 -03:00
Hisham Muhammad 76a715ee8c Fix order of calloc arguments.
(Patch by Dawid Gajownik)
2014-01-16 18:51:16 -02:00
Hisham Muhammad 00b324bfc1 Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers. 2012-12-05 15:12:20 +00:00
Hisham Muhammad 2a73405cd0 search and filter for the strace and lsof screens! 2012-11-10 00:31:37 +00:00
Hisham Muhammad 84281bdc44 major header cleanup 2011-12-26 21:35:57 +00:00
Hisham Muhammad 81e44312b4 Use strdup explicitly 2011-12-25 20:23:53 +00:00
Hisham Muhammad 7ca1081712 Mega-commit with features and tweaks for 1.0:
* 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.
2011-11-18 06:08:56 +00:00
Hisham Muhammad 7d7118b1f6 launch lsof for parent process when called on threads. 2011-03-22 22:09:42 +00:00
Hisham Muhammad b2fee47a14 don't resolve port names 2010-09-02 20:26:16 +00:00
Hisham Muhammad 6486229308 add support for steal/guest CPU time measurement
simplify processor data accounting (add CPUData structure)
remove Process_clone trick
2010-08-24 23:20:38 +00:00
Hisham Muhammad 282f16c4b8 fix memory leak 2010-03-03 21:10:51 +00:00
Hisham Muhammad 02a30bfecd warning fixes 2010-02-25 01:43:18 +00:00
Hisham Muhammad 7dcd2beb90 extra checks for lsof failures 2009-10-16 20:15:01 +00:00
Hisham Muhammad 3e6be2d7f7 fix to minor bug affecting the build process, a maintenance release will follow shortly. 2009-06-08 21:08:02 +00:00
Hisham Muhammad 7ee2646808 oops, add missing files 2009-06-02 19:28:19 +00:00