-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance and code style, refactor, partial rewrite (#17)
* Improve readability (uniformity, naming, includes) * De-cluttering, new types, reduced usage of globals * Introduce new enums, change format functions * Change to realtime clock * Improve performance and style, partial rewrite This commit addresses TODO#2 by universalizing the functions handling the zombie processes and sending `SIGCHLD` in the case where the user did not explicitly tell the program to reap zombies (reflected in the `terminate` member of our settings. Whenever a signal is sent, the used signal is displayed to the user. Some parts of old functions were put into new functions to also improve readability. The most substantial improvement lies in the performance aspect of the program. The use of `nftw()` in the old code was the biggest bottleneck, as an insane, unnecessary number of syscall are issued for each process. Thus, the directory and file reading part was adapted, using manual `readdir()` calls. As the `-f` flag did not make sense to have in the program anyway (and could lead to OOM kill), it was also dropped. Regex was also dropped, as its use was unnecessary and complicated things, and the parsing of `"/proc/<pid>/stat"` was rewritten. As kernel processes were not excluded in the program before, this commit checks for processes which should be left out of our considerations (PID `2`, as well as its children; `init` is also excluded). Display widths for the output are now defined in the accompanying header, and should be in line with the `proc(5)` documentation. The code for the prompt was improved with respect to the handling of invalid user input and coloring. Finally, to completely remove the unnecessary globals, a vector structure was defined in the header, which can dynamically grow. As the old version of the code did not check for overflows in this context, this is also a great improvement. * Add newline at end of file in Dockerfile * Adapt code in `zproc.c` to match `zps.{c,h}` * Update manpage to match source * Remove the `-f` flag test * Remove unnecessary comments and update category * Add missing newline at EOF in `CMakeLists.txt` * Remove notions of `-f` from the READMEs * Add a `.clang-format` file consistent with sources * Remove the other `-f` test * Add missing `<limits.h>` include * Use custom signal abbreviation function * Remove `stdlib.h.gcov` from `rm` command * Change array to `static` * Remove redundant print (will never happen (`proc(5)`) * Add `const` qualifiers to be more clear * Add even more `const` qualifiers * Change function pre-conditions to `assert()` calls * Bump version Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com> * Drop unused macro * Define `NDEBUG` in `CMakeLists.txt` and `Makefile` This will disable the pre-condition assertions in all functions, which should never be false for releases anyway. * Extend color functionality, refactor CLI options This commit ... * allows users to directly specify signals to send to zombie parents (using common signal numbers, abbreviations and abbreviations with "sig" in front of them (case-insensitive) * changes existing command-line options to simpler ones * places constraints on the possible combinations of command-line options used * adds functionality to detect if the program's output is, for example, piped to another program that will automatically disable ANSI color codes * adds a `--no-color` option to manually disable the default coloring The manual page and READMEs would still need to be updated. * Update tested flags * Update demos, READMEs and help texts * Bump year * Improve code clarity and remove TODOs (issues TBA) * Disable runtime assertions for the `Dockerfile` --------- Co-authored-by: Matthäus Wininger <matthaeus dot wininger at univie dot ac dot at> Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
- Loading branch information
1 parent
f15cd84
commit 76ffe80
Showing
18 changed files
with
1,162 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
[Desktop Entry] | ||
|
||
# Type | ||
Type=Application | ||
|
||
# The name of the application | ||
Name=zps | ||
|
||
# Application comment | ||
Comment=A small utility for listing and reaping zombie processes. | ||
|
||
# The executable of the application | ||
Exec=zps | ||
|
||
# Name of the icon | ||
Icon=utilities-system-monitor | ||
|
||
# Run in terminal | ||
Terminal=true | ||
|
||
# Categories | ||
Categories=Utility;ConsoleOnly;Monitor; | ||
|
||
# Don't display zps in the menus | ||
NoDisplay=true | ||
Categories=System;Monitor;ConsoleOnly; | ||
NoDisplay=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
--- | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AlignArrayOfStructures: Right | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: false | ||
AlignConsecutiveMacros: true | ||
AlignEscapedNewlines: Left | ||
AlignOperands: true | ||
AlignTrailingComments: false | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: false | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Custom | ||
BreakBeforeInheritanceComma: false | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: false | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '.*' | ||
Priority: 1 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IndentCaseLabels: false | ||
IndentGotoLabels: false | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 4 | ||
ObjCSpaceAfterProperty: true | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 10 | ||
PenaltyBreakBeforeFirstCallParameter: 30 | ||
PenaltyBreakComment: 10 | ||
PenaltyBreakFirstLessLess: 0 | ||
PenaltyBreakString: 10 | ||
PenaltyExcessCharacter: 100 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
ReflowComments: false | ||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatementsExceptForEachMacros | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 4 | ||
UseTab: Never | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.