fix readme
This commit is contained in:
parent
a1e7b25ad0
commit
24c928aea2
10
README.md
10
README.md
@ -3,12 +3,12 @@
|
||||
|
||||
Nohang is a highly configurable daemon for Linux which is able to correctly prevent [out of memory](https://en.wikipedia.org/wiki/Out_of_memory) (OOM) and keep system responsiveness in low memory conditions.
|
||||
|
||||

|
||||
|
||||
## What is the problem?
|
||||
|
||||
OOM conditions may cause [freezes](https://en.wikipedia.org/wiki/Hang_(computing)), [livelocks](https://en.wikipedia.org/wiki/Deadlock#Livelock), drop [caches](https://en.wikipedia.org/wiki/Page_cache) and processes to be killed (via sending [SIGKILL](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL)) instead of trying to terminate them correctly (via sending [SIGTERM](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM) or takes other corrective action). Some applications may crash if it's impossible to allocate memory.
|
||||
|
||||

|
||||
|
||||
Here are the statements of some users:
|
||||
|
||||
> "How do I prevent Linux from freezing when out of memory?
|
||||
@ -27,7 +27,10 @@ Also look at [Why are low memory conditions handled so badly?](https://www.reddi
|
||||
|
||||
- Use of [earlyoom](https://github.com/rfjakob/earlyoom). This is a simple and very lightweight OOM preventer written in C (the best choice for emedded and old servers). It has a minimum dependencies and can work with oldest kernels.
|
||||
- Use of [oomd](https://github.com/facebookincubator/oomd). This is a userspace OOM killer for linux systems whitten in C++ and developed by Facebook. Needs Linux 4.20+.
|
||||
- Use of nohang (maybe this is a good choice for modern desktops and servers if you need fine tuning).
|
||||
- Use of `nohang` (maybe this is a good choice for modern desktops and servers if you need fine tuning).
|
||||
|
||||

|
||||
|
||||
|
||||
The tools listed above may work at the same time on one computer.
|
||||
|
||||
@ -211,6 +214,7 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe
|
||||
- Add the ability to send any signal instead of SIGTERM for processes with certain names
|
||||
- Handle `UnicodeDecodeError` if victim name consists of many unicode characters
|
||||
- Improve user input validation
|
||||
- Fix `mlockall()` using `MCL_ONFAULT` and lock all memory by default
|
||||
|
||||
- [v0.1](https://github.com/hakavlad/nohang/releases/tag/v0.1), 2018-11-23
|
||||
- 1st release
|
||||
|
15
nohang
15
nohang
@ -427,7 +427,7 @@ def send_notify_etc(pid, name, command):
|
||||
pid: str process pid
|
||||
"""
|
||||
title = 'Hang prevention'
|
||||
body = 'Victim is process <b>{}</b> [{}]\nExecute the command:\n<b>{}</b>'.format(
|
||||
body = 'Victim is process <b>{}</b>, {}\nExecute the command:\n<b>{}</b>'.format(
|
||||
name.replace('&', '*'),
|
||||
pid,
|
||||
command.replace('&', '*')
|
||||
@ -691,8 +691,12 @@ def find_victim_and_send_signal(signal):
|
||||
|
||||
len_vm = len(str(vm_size))
|
||||
|
||||
try:
|
||||
realpath = os.path.realpath('/proc/' + pid + '/exe')
|
||||
except FileNotFoundError:
|
||||
print('Victim died: /proc/{}/exe does not exists'.format(pid))
|
||||
|
||||
|
||||
realpath = os.path.realpath('/proc/' + pid + '/exe')
|
||||
state = pid_to_state(pid)
|
||||
pname = pid_to_name(ppid.strip('\n '))
|
||||
# print([ppid], [pname])
|
||||
@ -736,10 +740,9 @@ def find_victim_and_send_signal(signal):
|
||||
cmdline
|
||||
)
|
||||
else:
|
||||
|
||||
|
||||
|
||||
# нахер такое ветвление
|
||||
|
||||
|
||||
victim_info = '\033[4mFound a process with highest badness:\033[0m' \
|
||||
'\n Name: \033[33m{}\033[0m' \
|
||||
'\n PID: \033[33m{}\033[0m' \
|
||||
@ -958,11 +961,13 @@ def calculate_percent(arg_key):
|
||||
|
||||
##########################################################################
|
||||
|
||||
# Lock all memory
|
||||
|
||||
|
||||
mlockall()
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
|
||||
# find mem_total
|
||||
|
Loading…
Reference in New Issue
Block a user