btop/src/btop.cpp

997 lines
31 KiB
C++
Raw Normal View History

2021-05-06 20:32:03 +02:00
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
indent = tab
tab-size = 4
*/
2021-06-09 19:47:49 +02:00
#include <csignal>
#include <clocale>
2021-08-03 23:47:46 +02:00
#include <pthread.h>
Squashed commit of the following: commit 7add05599de74d8047a9802fd673ae62a91a3372 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:48:16 2022 +0100 bring in line with upstream commit ddb2fb0fac530ef10a20413f311e3d970d038d3f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:35:21 2022 +0100 fix CPU name commit 01a1dda7346e9c1842225a3883e7dc5b99cdfc56 Merge: 3b6dac6 96ac114 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:29:17 2022 +0100 merge main into freebsd commit 3b6dac640e70613b5549db291781e25fa6506202 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:17:07 2022 +0100 disk IO working commit 30b33730b3de6567e5df3243fd372eb30123c181 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 22:47:44 2022 +0100 reduce memleak drastically commit 682746ff0ee6c8b83f52bc44e44dd29dc9d7cdd2 Merge: 9fdf6d0 891051c Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Dec 18 19:50:13 2021 +0100 Merge pull request #186 from GuillaumeGomez/freebsd Remove duplicated fstype commit 891051c8ab9984f155caa6bac2d170b0bb7d2a06 Author: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sun Dec 5 23:03:17 2021 +0100 Remove duplicated fstype commit 9fdf6d02044615da8b2c827abc002b2b71dd6db8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 27 20:55:49 2021 +0100 iterate over ALL pools commit 860a9fe472c7f4b6cc3f2ef38fb06101f5af7e21 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 27 20:30:43 2021 +0100 RAII commit 7c433be4a6b6b0cac84713e976a63d661a9338ae Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Nov 21 21:36:44 2021 +0100 regular filesystems + ZFS commit 70d9777908e8cd37088e1e19b8eb864a4357daba Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 20 22:57:00 2021 +0100 some comment + minor cleanup commit a61df3ff9815463da1cc0bdc713aa20dddc3b95e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 20 22:51:49 2021 +0100 it does some IO!! commit f32358bd47802b7af2ef5fe7f03bb4d4b5c9d544 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 22:30:55 2021 +0100 correct unit number commit d12b4d9d2359c9216ad5977a60de85aea865a92b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:58:12 2021 +0100 readability commit a6602ff22b4b00ecb7138a09f5c5a15e1b13ca62 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:53:33 2021 +0100 correctly iterate over devstat. still no idea how to map the devices we get back here to mountpoints commit e64610a163c23ec862c5f65d1accdd10a6163d47 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:20:42 2021 +0100 RAII commit 98693aac2502ac4903b95dffcbc9664abe7c4739 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 24 21:04:04 2021 +0200 devstat WIP commit 8940d68f47e3c22e9372495752ff16de2fa122b0 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 16:15:29 2021 +0200 Fixed cpu usage in cpu box, process cpu usage still wrong commit b547ccb25816497e5b31581d4cc102a24c1ec00a Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:25:28 2021 +0200 Makefile even with OSX Makefile commit a5eabe20b6dc11367a49c51b614769bbb2436e1d Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:20:46 2021 +0200 Updated Makefile commit 18451ceb0587d8304997f0e202117a73e5986b70 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:13:15 2021 +0200 Updated Makefile commit ca183b2b85fe729a8974715054bac4dc9d96d4a4 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:09:29 2021 +0200 Fixed up Makefile commit 235c95274f7ddd4a555ab1eb341776e0bd2c1dc5 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 23:49:51 2021 +0200 fix boottime (not sure if needed) commit cc2a4987efde6f3cf8ef8ab96d6793c8220375cb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 23:38:00 2021 +0200 temp commit 30ef6ee05057c6bbb0ddc96b7897de31e692907c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 22:58:17 2021 +0200 cpu freq commit 735894b6caddedcf69a200e9d29cf0115c08bcce Author: aristocratos <gnmjpl@gmail.com> Date: Sat Oct 23 21:46:57 2021 +0200 Fixed leaks and proc tree mode commit cd3fd1a529f72eba979607f6e758ea855e01fd79 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 22:27:32 2021 +0200 correct makefile commit cd644cfc55de21312d1492f8a8c285cfcfe44535 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:49:39 2021 +0200 get rid of warnings commit 81b63652bfbaaa50d4da16f9e76a2d96036ba434 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:43:22 2021 +0200 battery commit 41ba98695400a1a82aa6ddb884344b7c1e556f49 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:31:04 2021 +0200 process args commit 137e876da636963ba2e758ea9fe3f4e91f15a662 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 14:29:36 2021 +0200 remove debug commit 5249be0a40d12081ebdea05d6e3cad5c6bfa9e11 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 14:28:40 2021 +0200 net stats commit 96461f4d948a29bbd6748223e8bb014c8d2f2902 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 13:54:00 2021 +0200 sane memory stats commit e5ceeee1978ed5121f157da554fad9f51e1a5de1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 13:38:27 2021 +0200 processes commit 889433d4c651e3f7f9466f2b7d3353cc664c5950 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 12:08:47 2021 +0200 cpu model + cpu load commit f037ab306a6e08bc4582933f6ecc8cf352dae6cd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 10:31:37 2021 +0200 freebsd first work commit de6216792154477a5ab7f564c9467761daf842e2 Merge: a590dd3 a0ee404 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 20 23:10:36 2021 +0200 Merge branch 'main' into OSX # Conflicts: # CHANGELOG.md # Makefile # src/btop.cpp commit a590dd3f67c9f2f8f8dc3fa49920a40a5e8b369d Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 18 11:20:12 2021 +0200 Ignore format-truncation commit 4c30742d412cf552de22b3746a68cd62bfe867f2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 18 10:08:01 2021 +0200 comments about temp sensors commit 46030de77cb1409eb8b0247c331408a240b0227a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 18 08:10:37 2021 +0200 available = total - used commit 4c228de0ef8a75275178bad081e568f85fc579fd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:19:41 2021 +0200 use sysconf to get arg_max - seems simpler commit c60fc29f0f62831730c04c23cd9ffbefef50a1d8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:10:50 2021 +0200 arg_max should be int on macos commit 0b5a931a6d5e8d1a434e88e8fd0613ab948995fa Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:01:42 2021 +0200 only fetch max_args once commit 71d5cd5fd91511a90e43e5e6dbf7a1b6a3c3f9c8 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 23:24:07 2021 +0200 Reverted mutexes back to custom atomic bool based locks commit 3f34a67df68f3f451cb48b023b7cd42ccf933ce4 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:47:55 2021 +0200 these helpers can be static commit fc19c46c8aab03e252f60f6f9447d7e1861cbcb9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:44:49 2021 +0200 code cleanup: put the code in .cpp to enable incremental build commit c252c618c043c4b85783f56363121877d0db0727 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:09:21 2021 +0200 don't crash on intel commit 9f88187c29821148c7a5272926d204bd3eb39f89 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:06:18 2021 +0200 small improvement commit 808f09c97465e8cf511f7690b40a69cd8a2efa15 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 20:59:48 2021 +0200 don't iterate 3 times commit d8408336e3b8336025a087a2bf79a2d15f51ee66 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 20:59:27 2021 +0200 remove debug commit 4f078c3beb960fe06f4d8b44b9c913e2aacf7625 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 13 23:38:27 2021 +0200 more temperature (M1 + intel) commit 289880aaa6d1a3625c01e9d7643138343b29db53 Merge: 88a2528 3ffb212 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 19:37:09 2021 +0200 Merge branch 'OSX' of github.com:aristocratos/btop into OSX commit 88a2528ca3a2390f2c94c7f1a18ba982a5e5f2b2 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 19:34:10 2021 +0200 Merge changes from main commit 3ffb21203aa3f4ad978533a3f2b1e67e636381ea Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 19:20:45 2021 +0200 release a bit more - still has negative temps for 2 cores on my system commit 70b48710626ba22df496ba741625ce03cba6abbd Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 01:59:44 2021 +0200 Fixed leaks in Mem and attempt at fixing leaks in sensors.cpp commit fbae907720afbae47162666b6b0aea974be80c07 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 15 23:41:37 2021 +0200 temperature sensors via IOKit commit cef0f0a68daa88a380000ce200a364e4701ba93a Author: aristocratos <admin@qvantnet.com> Date: Fri Oct 15 18:39:17 2021 +0200 Process command line arguments commit 921cfa01ffc104c57f2825d0bca648233ddff191 Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 23:20:15 2021 +0200 Re-enable setuid and set default SU_GROUP to wheel for OSX commit a416c888c7356634ef7a5286130a56160d72f50a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 13 21:16:41 2021 +0200 temperature commit e7afe00ce7960bfe6fb6ba2a9a2f5d498c5b4fca Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 12:54:43 2021 +0200 Cpu usage working again commit 4193ef8921617e48ce07ce95d898386f7dd77f43 Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 10:36:51 2021 +0200 Fixed cpu lazy sorting commit 93fcb6ff04d84c008ed9f7d28918eb9eb8adf740 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 22:22:45 2021 +0200 Update README.md commit 683354cd2ed8add79c6940e51800431e8b020635 Merge: 8a399c4 6d724d6 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 22:19:30 2021 +0200 Merge pull request #80 from ShrirajHegde/OSX Add github workflow for MacOS commit 8a399c499af87883a7e4b2cf7f6d193f76909923 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 21:50:46 2021 +0200 pointer to smart pointer, first pass commit 772605003af9c1c00f163ff75279cd0055074c96 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 18:54:38 2021 +0200 Fixed detailed memory not updating commit 28cb67753332fe8c93d23cbf8e4db636fc6823d6 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 11 22:19:25 2021 +0200 more memory free-up - still leaks like crazy commit 304457863f6cdccf82fbe1cca3078c7f5d9f97cd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 11 21:48:07 2021 +0200 more RAII cleanup commit 82e2e3c55c23e37dbf226952cca4587df3522fa3 Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 11 12:40:25 2021 +0200 Removed non present cpu fields and fixed calculation for selectable cpu field graphs commit 68603f2b37e34828f78f0f675f66bd835dae8325 Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 11 10:57:04 2021 +0200 RAII Wrappers for Cpu::get_battery() commit d5cb24fbeb19ae57507e1715aa402b2dc33f9b6b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 10 20:23:11 2021 +0200 RAII commit 8fad5a61bee973c22f3a11fd7fee2c4e40390bbb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:44:16 2021 +0200 get more disk IO stats commit 7fa903cf160b391fb316ea32a60984921a174066 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:43:48 2021 +0200 fix build commit 98036db660e306626d41fb1b67d9938d9ffe168a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:18:25 2021 +0200 remove unnecessary uptime param commit aae7ae35caec64ba611d9b78b24c0ad2716f333e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:07:23 2021 +0200 remove debug logging commit 5187420b04973edcdd25c1b639795a2c8539b2d9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:06:43 2021 +0200 fix process elapsed time commit 89582c0ea6e9bdd7a658b5583d2ce2c5deeee8b0 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:06:29 2021 +0200 don't double free commit 6d724d6155bad8c084e4c9bdb1d7dda13543a5ac Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:46:33 2021 +0530 Change Upload filename commit 4f94ecc8ad7d7cdb7daed82fd98a5634d723ec6b Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:40:11 2021 +0530 Fix upload path commit e1d6d0a1f224474417078a0a1b98a6c4b5c94a53 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:36:13 2021 +0530 Skip installing gcc via Homebrew Change job name commit 02cdd9d759d163519048d24746273e4eda2149d0 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:30:40 2021 +0530 Fix uploading Remove distclean commit 39eb6c396fc31f798d23c21e7f4b313930dca982 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:26:57 2021 +0530 Disable static compilation commit 099592bccdafe8d8d8c421bcad3e036cbea580ce Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 17:52:10 2021 +0200 Ignore empty pid 0 to fix tree mode commit a28e17556e74bb618fc2b6eb74f250b139406cdd Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:17:11 2021 +0530 Add workflow for MacOS commit aee9179c0a98bce54b55c8bb8ebdc1ac99bad69e Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 17:36:46 2021 +0200 Disable failed tty mode detection for OSX commit 4b7b98058d7190a494fa522834217d786d71e5fb Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 11:28:32 2021 +0200 Fixed disk io and added io activity based on read/write commit bfa0629e7d1e50f88d9a1207930e2f39270fc189 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 22:28:10 2021 +0200 fill in 0 for ioticks commit a016ff8a039634bc37a22a4a84b31055b3cfab37 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 22:16:01 2021 +0200 disk io from IOreg. Does not show any io though commit f98606c6db09d50c7ae234437ea03eda2cc8739c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 09:32:06 2021 +0200 per process IO stats commit c8b50ed4883103f66c9ed869fd0252d48f18f58f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 00:11:08 2021 +0200 don't show autofs, it's useless commit c4df64d4409c511847d76b37a0794b8bb4f6942d Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:41:49 2021 +0200 Fixed compile time display for gmake and command timings commit b3e6f495f76bd71fba3442a557df22afdd3e642d Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:26:15 2021 +0200 Fixed clk_tck -> clkTck commit e53799188ffc24f3948e7ced375b7fbb53911247 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:25:14 2021 +0200 Fixed better detection for OSX commit b864edf984e8f0daa0f10a6ee305074c68efeb42 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:24:37 2021 +0200 Fixed cumulative cpu usage commit 6a3c5d9b976c711461d08c373483c84bb69db257 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 13:20:30 2021 +0200 Proc::collect() better cpu percent accurazy commit 84d0596294432baef1b10f7d3a566a07382f69d3 Merge: 3564f8e 98e1e87 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 12:56:55 2021 +0200 Merge branch 'OSX' of github.com:aristocratos/btop into OSX commit 3564f8e4c26f04ec89482606e68a452a3e5f9693 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 12:56:27 2021 +0200 Proc::collect() fixed cputimes and cpu percentage calc commit 98e1e874059fe69968d4bb7e4685f292e3b7fd65 Merge: 60c5636 d96fdd7 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Thu Oct 7 11:32:41 2021 +0200 Merge branch 'main' into OSX commit 60c5636cd7c18e6c806cb4cd88846db10092dd57 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:45:54 2021 +0200 fix warning commit 489e446152ce00f8e92db8c4e10759f96e38f17f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:38:40 2021 +0200 details + process states commit 7e5a808c731772bab35204f2e286975fca334f54 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:38:19 2021 +0200 avoid details crash commit 9c9da4606b3f93c0701b820a875fb3db5d0c3daf Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 21:03:21 2021 +0200 fix quit on macos commit ec7415384d9d9b42892a1e36ff55bf7a117a253b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:41:37 2021 +0200 fix mistake in makefile commit 5ac8fa4c8a8f73efac6ac1f15e458ed3b2c1164b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 18:56:13 2021 +0200 don't show /dev commit d901bbebd94ec45c45431fcd1ab37a974f783d9b Author: aristocratos <gnmjpl@gmail.com> Date: Wed Oct 6 17:27:51 2021 +0200 Ignore tags and other branches commit c7f1e71e29bafb5334cd4e256c662e5ee6303b1b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 16:00:41 2021 +0200 comment commit b9d58e3faf5b60ad4f5f65454b454ff52deb5eaa Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:55:58 2021 +0200 impossible to get CPU freq on M1 apparently commit 66072711c24b2694c4a0054c58829095ed97ada2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:33:43 2021 +0200 detect full commit 6bb0e930a2c44b4fb7d0d02a40f210fa12fdc657 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:38:46 2021 +0200 CPU freq in GHz commit a5f10f1a0ff9d10fa8d9d3038aa160b2380aa294 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:13:18 2021 +0200 check array length commit 155c848b97e1385bd29eaba91a87ecfb1d846bf7 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:05:20 2021 +0200 switch to other way to get CPU freq (still does not work) commit cf51ba2ebe88dddd943040ced484581dc260c3c8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:45:44 2021 +0200 remove some warnings commit 775dff5f72b0631bba0ed01d72374d8c1d1cd059 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:16:45 2021 +0200 fix link commit 8c67967775fb98bda80eee40cb6833a00bfb93a1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:16:38 2021 +0200 reduce diff more commit 70b47d2ca8a7e0927cf9613e8fe776d2405f60ee Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:10:23 2021 +0200 reduce diff with main branch commit ca9cb48054c5850cbb3c23d368e04644a1885de0 Merge: d0c6c0a c66b46f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 13:49:20 2021 +0200 Merge remote-tracking branch 'origin/main' into OSX # Conflicts: # Makefile # src/osx/btop_collect.cpp commit c66b46f850d31c100226e519c55b39df9129aeb8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 13:41:57 2021 +0200 battery state via CoreFoundation commit d0c6c0a362d8dc4f76e2901d7b406a70d8a69b6b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:51:36 2021 +0200 all disks + load averages commit ca67526dc175dba7d98193a6462e70ef1acab194 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:33:55 2021 +0200 show all disks commit 56119f99a95ca541d6ab744a9ded54c84e0a3184 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:17:41 2021 +0200 procs sorting/filtering commit 8d86011d72a07b3f86f6b525b026b805667a3172 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:42:17 2021 +0200 battery states commit a9b64d62e4abf96fe3edcfa660871caef2041d0f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:24:59 2021 +0200 battery hack works on M1 commit ce5103114246f5549017ef4823442a0ea916e1dd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:18:22 2021 +0200 ugly hack to get battery commit d5e6725c6cd6973cc75dfe2993892e1c25ac8d38 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 22:42:42 2021 +0200 CPU stuff commit 5c02bd8c8380c5c74837b982987b7bf31103245f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 21:25:42 2021 +0200 network commit d5da9d49835cdb23ad5830c000e1b93fcb8f46fd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 15:43:05 2021 +0200 correct cached size commit 5f11aba504254d86ed9a2319967590d50988e16f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 12:03:48 2021 +0200 vm stats from syscall + swap commit 776fc968529e8e7e38fc3168c83b2727198722ad Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:48:07 2021 +0200 seems to work indeed commit 7b40e2835a085bfe0d5eb40f367a1ed50353e4d9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:46:14 2021 +0200 allow override optimization flag commit 005ea24e4c9bcc6608671a0635126bf10bdece34 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:09:24 2021 +0200 update Makefile commit af8cec9debac328645f0f4e2f136e4572d88332e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:32:55 2021 +0200 some more params commit 7ebe4f7594599ccafbf72a004ce37f965549f64d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:15:55 2021 +0200 show more disks commit e50a56394a3702b6616d03694f5d23a5f7ba2f1c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 14:52:56 2021 +0200 disks show something commit 6497a8c2021b67057dfed26488aec0d82e919a90 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 09:15:35 2021 +0200 reformat commit 28e152b80c07c1fb9a4049cca8510f8bdc31adbb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 23:21:13 2021 +0200 decrease diff with upstream commit 40da88e9ca91f3db540b63b15da5bc34dc9175e9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:56:14 2021 +0200 try to get disks to show commit eaf2bb56a503fd2bf3787bfd90b5bc8640b7d628 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:42:01 2021 +0200 don't crash on deque::back() commit f66b6f712c361fafbe6d0cfd8f8c0838dc1bb4d2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:21 2021 +0200 cpu freq, name & process uid/name commit 34a8a61f4de964d3137637b045be8738c4b1b6e5 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:46:11 2021 +0200 basic process info commit 29bb2dcc5fcc6b946511068f036590c18fb459ce Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:45:39 2021 +0200 initialize mutex (needed on macos apparently and not on linux) commit fb5970b0005793d760e652348d6acc30fb570f70 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:53:41 2021 +0200 comment commit 49d16cdddd56ba5631269eb2ffbec87d9f36f81e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:51:29 2021 +0200 extract delimiters commit 3db9d6647650bd836201b8150e320a7fbf28e3c2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:28 2021 +0200 first infos on macos: memory used & free commit f8acb2f8542429677116799ddb5f442488cf3f4f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Sep 28 23:37:03 2021 +0200 make it compile on macos (M1 - arm64). Does not run though commit bbba17cd35248e4e9ec9bfc1b113758cfcffde1f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:51:36 2021 +0200 all disks + load averages commit 548203e93dfaf3ec9f24086bee08aac85891c4df Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:33:55 2021 +0200 show all disks commit 0ab2be39857fb3dcdb13b49bc9155f17c7d82a4e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:17:41 2021 +0200 procs sorting/filtering commit 096104c90b571e931a3a7d9c813dbfc9aa47e212 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:42:17 2021 +0200 battery states commit 0ad93684c2a72293b23d6a2163c9ec51b499dfa3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:24:59 2021 +0200 battery hack works on M1 commit c75b0f1cea34e6c4c70332ba7e2572ec9b70deef Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:18:22 2021 +0200 ugly hack to get battery commit 600b4f72b3bbbcd85bf5d148942bce7be8cf0b72 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 22:42:42 2021 +0200 CPU stuff commit 4eb812d52c6e179ae386df0156021d7c35cbe5a3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 21:25:42 2021 +0200 network commit 899be68a78270216bfdcca5f0c87668a87c8792f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 15:43:05 2021 +0200 correct cached size commit a1c7f935e3a5661688c0de1ad3226f7bc43b9979 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 12:03:48 2021 +0200 vm stats from syscall + swap commit bd1050a7404f9766a0125523c868a27d5cfac8e8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:48:07 2021 +0200 seems to work indeed commit 5094b73758ee88617e8d5ce876211e1efa298769 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:46:14 2021 +0200 allow override optimization flag commit 8811270332bc2276cd18c1116f4d3c2d64a6f721 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:09:24 2021 +0200 update Makefile commit 42f966f448b9ad571db7849dc8fd525e0fe72309 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:32:55 2021 +0200 some more params commit c1e6d6a62e2810f80fac372e666ec169540b0591 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:15:55 2021 +0200 show more disks commit 50fcdaa8543f717bf36146cfa38636fd39009f23 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 14:52:56 2021 +0200 disks show something commit 264bf2d7da0e3fabb5987cddee73762e52170a51 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 09:15:35 2021 +0200 reformat commit 1fd625086ba42e9440c463ae940563d934b8b5c3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 23:21:13 2021 +0200 decrease diff with upstream commit 17f9f3703c1dd52a86176131a2239cd52ee285bd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:56:14 2021 +0200 try to get disks to show commit 8462ae6431fcfe1985d1bbb4404452ddc03cc1de Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:42:01 2021 +0200 don't crash on deque::back() commit 78bce5b5a6c1c0f3b38f802acad49ec2e32482d6 Merge: 53e379d f9505a4 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:34 2021 +0200 Merge branch 'aristocratos:main' into main commit 53e379d74dffe2282b089450728501b51d13d199 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:21 2021 +0200 cpu freq, name & process uid/name commit 2a44b307ef9e947c1007a86988876668a5731e64 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:46:11 2021 +0200 basic process info commit 66534eb5b50753217687de0414d390bcb2a14cf1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:45:39 2021 +0200 initialize mutex (needed on macos apparently and not on linux) commit 0983917f26948d83fd8da103903ec99f88058d87 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:53:41 2021 +0200 comment commit 9732507248b30139d4af54615945c0b4737cff7d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:51:29 2021 +0200 extract delimiters commit 6e704ce8387041c33022459fb6a084362f82a72c Merge: fe4db7c 7bfbd83 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:43 2021 +0200 Merge branch 'main' of github.com:joske/btop commit fe4db7c16cd349053385eda62e9f2df2e7344d3d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:28 2021 +0200 first infos on macos: memory used & free commit 7bfbd83a476c8cbe3b74e22b1e44f201026bf9d1 Merge: 8c8139b a15f961 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 1 17:05:26 2021 +0200 Merge branch 'aristocratos:main' into main commit 8c8139bd1df0849061b5e1425a3138d5f45ec149 Merge: 679d21c a246c09 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 21:50:00 2021 +0200 Merge branch 'aristocratos:main' into main commit 679d21cd223b1928e8dde95cac25e8bfb412bedf Merge: 4c70c5b a49b8f9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 20:23:34 2021 +0200 Merge branch 'aristocratos:main' into main commit 4c70c5bdd98bfcc0ae9d9d9e8e3713dc8af71d03 Merge: 84a9746 c70667e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 08:30:05 2021 +0200 Merge branch 'aristocratos:main' into main commit 84a974695afaadc53d1d8576ea66255166ede482 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Sep 28 23:37:03 2021 +0200 make it compile on macos (M1 - arm64). Does not run though
2022-01-12 00:04:26 +01:00
#ifdef __FreeBSD__
2022-01-16 14:19:31 +01:00
#include <pthread_np.h>
Squashed commit of the following: commit 7add05599de74d8047a9802fd673ae62a91a3372 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:48:16 2022 +0100 bring in line with upstream commit ddb2fb0fac530ef10a20413f311e3d970d038d3f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:35:21 2022 +0100 fix CPU name commit 01a1dda7346e9c1842225a3883e7dc5b99cdfc56 Merge: 3b6dac6 96ac114 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:29:17 2022 +0100 merge main into freebsd commit 3b6dac640e70613b5549db291781e25fa6506202 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 23:17:07 2022 +0100 disk IO working commit 30b33730b3de6567e5df3243fd372eb30123c181 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Jan 11 22:47:44 2022 +0100 reduce memleak drastically commit 682746ff0ee6c8b83f52bc44e44dd29dc9d7cdd2 Merge: 9fdf6d0 891051c Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Dec 18 19:50:13 2021 +0100 Merge pull request #186 from GuillaumeGomez/freebsd Remove duplicated fstype commit 891051c8ab9984f155caa6bac2d170b0bb7d2a06 Author: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sun Dec 5 23:03:17 2021 +0100 Remove duplicated fstype commit 9fdf6d02044615da8b2c827abc002b2b71dd6db8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 27 20:55:49 2021 +0100 iterate over ALL pools commit 860a9fe472c7f4b6cc3f2ef38fb06101f5af7e21 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 27 20:30:43 2021 +0100 RAII commit 7c433be4a6b6b0cac84713e976a63d661a9338ae Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Nov 21 21:36:44 2021 +0100 regular filesystems + ZFS commit 70d9777908e8cd37088e1e19b8eb864a4357daba Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 20 22:57:00 2021 +0100 some comment + minor cleanup commit a61df3ff9815463da1cc0bdc713aa20dddc3b95e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Nov 20 22:51:49 2021 +0100 it does some IO!! commit f32358bd47802b7af2ef5fe7f03bb4d4b5c9d544 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 22:30:55 2021 +0100 correct unit number commit d12b4d9d2359c9216ad5977a60de85aea865a92b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:58:12 2021 +0100 readability commit a6602ff22b4b00ecb7138a09f5c5a15e1b13ca62 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:53:33 2021 +0100 correctly iterate over devstat. still no idea how to map the devices we get back here to mountpoints commit e64610a163c23ec862c5f65d1accdd10a6163d47 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Nov 16 21:20:42 2021 +0100 RAII commit 98693aac2502ac4903b95dffcbc9664abe7c4739 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 24 21:04:04 2021 +0200 devstat WIP commit 8940d68f47e3c22e9372495752ff16de2fa122b0 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 16:15:29 2021 +0200 Fixed cpu usage in cpu box, process cpu usage still wrong commit b547ccb25816497e5b31581d4cc102a24c1ec00a Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:25:28 2021 +0200 Makefile even with OSX Makefile commit a5eabe20b6dc11367a49c51b614769bbb2436e1d Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:20:46 2021 +0200 Updated Makefile commit 18451ceb0587d8304997f0e202117a73e5986b70 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:13:15 2021 +0200 Updated Makefile commit ca183b2b85fe729a8974715054bac4dc9d96d4a4 Author: aristocratos <gnmjpl@gmail.com> Date: Sun Oct 24 11:09:29 2021 +0200 Fixed up Makefile commit 235c95274f7ddd4a555ab1eb341776e0bd2c1dc5 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 23:49:51 2021 +0200 fix boottime (not sure if needed) commit cc2a4987efde6f3cf8ef8ab96d6793c8220375cb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 23:38:00 2021 +0200 temp commit 30ef6ee05057c6bbb0ddc96b7897de31e692907c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 23 22:58:17 2021 +0200 cpu freq commit 735894b6caddedcf69a200e9d29cf0115c08bcce Author: aristocratos <gnmjpl@gmail.com> Date: Sat Oct 23 21:46:57 2021 +0200 Fixed leaks and proc tree mode commit cd3fd1a529f72eba979607f6e758ea855e01fd79 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 22:27:32 2021 +0200 correct makefile commit cd644cfc55de21312d1492f8a8c285cfcfe44535 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:49:39 2021 +0200 get rid of warnings commit 81b63652bfbaaa50d4da16f9e76a2d96036ba434 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:43:22 2021 +0200 battery commit 41ba98695400a1a82aa6ddb884344b7c1e556f49 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 15:31:04 2021 +0200 process args commit 137e876da636963ba2e758ea9fe3f4e91f15a662 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 14:29:36 2021 +0200 remove debug commit 5249be0a40d12081ebdea05d6e3cad5c6bfa9e11 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 14:28:40 2021 +0200 net stats commit 96461f4d948a29bbd6748223e8bb014c8d2f2902 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 13:54:00 2021 +0200 sane memory stats commit e5ceeee1978ed5121f157da554fad9f51e1a5de1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 13:38:27 2021 +0200 processes commit 889433d4c651e3f7f9466f2b7d3353cc664c5950 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 12:08:47 2021 +0200 cpu model + cpu load commit f037ab306a6e08bc4582933f6ecc8cf352dae6cd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 22 10:31:37 2021 +0200 freebsd first work commit de6216792154477a5ab7f564c9467761daf842e2 Merge: a590dd3 a0ee404 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 20 23:10:36 2021 +0200 Merge branch 'main' into OSX # Conflicts: # CHANGELOG.md # Makefile # src/btop.cpp commit a590dd3f67c9f2f8f8dc3fa49920a40a5e8b369d Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 18 11:20:12 2021 +0200 Ignore format-truncation commit 4c30742d412cf552de22b3746a68cd62bfe867f2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 18 10:08:01 2021 +0200 comments about temp sensors commit 46030de77cb1409eb8b0247c331408a240b0227a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 18 08:10:37 2021 +0200 available = total - used commit 4c228de0ef8a75275178bad081e568f85fc579fd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:19:41 2021 +0200 use sysconf to get arg_max - seems simpler commit c60fc29f0f62831730c04c23cd9ffbefef50a1d8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:10:50 2021 +0200 arg_max should be int on macos commit 0b5a931a6d5e8d1a434e88e8fd0613ab948995fa Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 17 22:01:42 2021 +0200 only fetch max_args once commit 71d5cd5fd91511a90e43e5e6dbf7a1b6a3c3f9c8 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 23:24:07 2021 +0200 Reverted mutexes back to custom atomic bool based locks commit 3f34a67df68f3f451cb48b023b7cd42ccf933ce4 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:47:55 2021 +0200 these helpers can be static commit fc19c46c8aab03e252f60f6f9447d7e1861cbcb9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:44:49 2021 +0200 code cleanup: put the code in .cpp to enable incremental build commit c252c618c043c4b85783f56363121877d0db0727 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:09:21 2021 +0200 don't crash on intel commit 9f88187c29821148c7a5272926d204bd3eb39f89 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 21:06:18 2021 +0200 small improvement commit 808f09c97465e8cf511f7690b40a69cd8a2efa15 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 20:59:48 2021 +0200 don't iterate 3 times commit d8408336e3b8336025a087a2bf79a2d15f51ee66 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 20:59:27 2021 +0200 remove debug commit 4f078c3beb960fe06f4d8b44b9c913e2aacf7625 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 13 23:38:27 2021 +0200 more temperature (M1 + intel) commit 289880aaa6d1a3625c01e9d7643138343b29db53 Merge: 88a2528 3ffb212 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 19:37:09 2021 +0200 Merge branch 'OSX' of github.com:aristocratos/btop into OSX commit 88a2528ca3a2390f2c94c7f1a18ba982a5e5f2b2 Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 19:34:10 2021 +0200 Merge changes from main commit 3ffb21203aa3f4ad978533a3f2b1e67e636381ea Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 16 19:20:45 2021 +0200 release a bit more - still has negative temps for 2 cores on my system commit 70b48710626ba22df496ba741625ce03cba6abbd Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 16 01:59:44 2021 +0200 Fixed leaks in Mem and attempt at fixing leaks in sensors.cpp commit fbae907720afbae47162666b6b0aea974be80c07 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 15 23:41:37 2021 +0200 temperature sensors via IOKit commit cef0f0a68daa88a380000ce200a364e4701ba93a Author: aristocratos <admin@qvantnet.com> Date: Fri Oct 15 18:39:17 2021 +0200 Process command line arguments commit 921cfa01ffc104c57f2825d0bca648233ddff191 Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 23:20:15 2021 +0200 Re-enable setuid and set default SU_GROUP to wheel for OSX commit a416c888c7356634ef7a5286130a56160d72f50a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 13 21:16:41 2021 +0200 temperature commit e7afe00ce7960bfe6fb6ba2a9a2f5d498c5b4fca Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 12:54:43 2021 +0200 Cpu usage working again commit 4193ef8921617e48ce07ce95d898386f7dd77f43 Author: aristocratos <admin@qvantnet.com> Date: Wed Oct 13 10:36:51 2021 +0200 Fixed cpu lazy sorting commit 93fcb6ff04d84c008ed9f7d28918eb9eb8adf740 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 22:22:45 2021 +0200 Update README.md commit 683354cd2ed8add79c6940e51800431e8b020635 Merge: 8a399c4 6d724d6 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 22:19:30 2021 +0200 Merge pull request #80 from ShrirajHegde/OSX Add github workflow for MacOS commit 8a399c499af87883a7e4b2cf7f6d193f76909923 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 21:50:46 2021 +0200 pointer to smart pointer, first pass commit 772605003af9c1c00f163ff75279cd0055074c96 Author: aristocratos <admin@qvantnet.com> Date: Tue Oct 12 18:54:38 2021 +0200 Fixed detailed memory not updating commit 28cb67753332fe8c93d23cbf8e4db636fc6823d6 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 11 22:19:25 2021 +0200 more memory free-up - still leaks like crazy commit 304457863f6cdccf82fbe1cca3078c7f5d9f97cd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 11 21:48:07 2021 +0200 more RAII cleanup commit 82e2e3c55c23e37dbf226952cca4587df3522fa3 Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 11 12:40:25 2021 +0200 Removed non present cpu fields and fixed calculation for selectable cpu field graphs commit 68603f2b37e34828f78f0f675f66bd835dae8325 Author: aristocratos <admin@qvantnet.com> Date: Mon Oct 11 10:57:04 2021 +0200 RAII Wrappers for Cpu::get_battery() commit d5cb24fbeb19ae57507e1715aa402b2dc33f9b6b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 10 20:23:11 2021 +0200 RAII commit 8fad5a61bee973c22f3a11fd7fee2c4e40390bbb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:44:16 2021 +0200 get more disk IO stats commit 7fa903cf160b391fb316ea32a60984921a174066 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:43:48 2021 +0200 fix build commit 98036db660e306626d41fb1b67d9938d9ffe168a Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:18:25 2021 +0200 remove unnecessary uptime param commit aae7ae35caec64ba611d9b78b24c0ad2716f333e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:07:23 2021 +0200 remove debug logging commit 5187420b04973edcdd25c1b639795a2c8539b2d9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:06:43 2021 +0200 fix process elapsed time commit 89582c0ea6e9bdd7a658b5583d2ce2c5deeee8b0 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 9 21:06:29 2021 +0200 don't double free commit 6d724d6155bad8c084e4c9bdb1d7dda13543a5ac Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:46:33 2021 +0530 Change Upload filename commit 4f94ecc8ad7d7cdb7daed82fd98a5634d723ec6b Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:40:11 2021 +0530 Fix upload path commit e1d6d0a1f224474417078a0a1b98a6c4b5c94a53 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:36:13 2021 +0530 Skip installing gcc via Homebrew Change job name commit 02cdd9d759d163519048d24746273e4eda2149d0 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:30:40 2021 +0530 Fix uploading Remove distclean commit 39eb6c396fc31f798d23c21e7f4b313930dca982 Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:26:57 2021 +0530 Disable static compilation commit 099592bccdafe8d8d8c421bcad3e036cbea580ce Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 17:52:10 2021 +0200 Ignore empty pid 0 to fix tree mode commit a28e17556e74bb618fc2b6eb74f250b139406cdd Author: Shriraj Hegde <shriraj.hegde@gmail.com> Date: Sat Oct 9 21:17:11 2021 +0530 Add workflow for MacOS commit aee9179c0a98bce54b55c8bb8ebdc1ac99bad69e Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 17:36:46 2021 +0200 Disable failed tty mode detection for OSX commit 4b7b98058d7190a494fa522834217d786d71e5fb Author: aristocratos <admin@qvantnet.com> Date: Sat Oct 9 11:28:32 2021 +0200 Fixed disk io and added io activity based on read/write commit bfa0629e7d1e50f88d9a1207930e2f39270fc189 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 22:28:10 2021 +0200 fill in 0 for ioticks commit a016ff8a039634bc37a22a4a84b31055b3cfab37 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 22:16:01 2021 +0200 disk io from IOreg. Does not show any io though commit f98606c6db09d50c7ae234437ea03eda2cc8739c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 09:32:06 2021 +0200 per process IO stats commit c8b50ed4883103f66c9ed869fd0252d48f18f58f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 8 00:11:08 2021 +0200 don't show autofs, it's useless commit c4df64d4409c511847d76b37a0794b8bb4f6942d Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:41:49 2021 +0200 Fixed compile time display for gmake and command timings commit b3e6f495f76bd71fba3442a557df22afdd3e642d Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:26:15 2021 +0200 Fixed clk_tck -> clkTck commit e53799188ffc24f3948e7ced375b7fbb53911247 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:25:14 2021 +0200 Fixed better detection for OSX commit b864edf984e8f0daa0f10a6ee305074c68efeb42 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 18:24:37 2021 +0200 Fixed cumulative cpu usage commit 6a3c5d9b976c711461d08c373483c84bb69db257 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 13:20:30 2021 +0200 Proc::collect() better cpu percent accurazy commit 84d0596294432baef1b10f7d3a566a07382f69d3 Merge: 3564f8e 98e1e87 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 12:56:55 2021 +0200 Merge branch 'OSX' of github.com:aristocratos/btop into OSX commit 3564f8e4c26f04ec89482606e68a452a3e5f9693 Author: aristocratos <admin@qvantnet.com> Date: Thu Oct 7 12:56:27 2021 +0200 Proc::collect() fixed cputimes and cpu percentage calc commit 98e1e874059fe69968d4bb7e4685f292e3b7fd65 Merge: 60c5636 d96fdd7 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Thu Oct 7 11:32:41 2021 +0200 Merge branch 'main' into OSX commit 60c5636cd7c18e6c806cb4cd88846db10092dd57 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:45:54 2021 +0200 fix warning commit 489e446152ce00f8e92db8c4e10759f96e38f17f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:38:40 2021 +0200 details + process states commit 7e5a808c731772bab35204f2e286975fca334f54 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 22:38:19 2021 +0200 avoid details crash commit 9c9da4606b3f93c0701b820a875fb3db5d0c3daf Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 21:03:21 2021 +0200 fix quit on macos commit ec7415384d9d9b42892a1e36ff55bf7a117a253b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:41:37 2021 +0200 fix mistake in makefile commit 5ac8fa4c8a8f73efac6ac1f15e458ed3b2c1164b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 18:56:13 2021 +0200 don't show /dev commit d901bbebd94ec45c45431fcd1ab37a974f783d9b Author: aristocratos <gnmjpl@gmail.com> Date: Wed Oct 6 17:27:51 2021 +0200 Ignore tags and other branches commit c7f1e71e29bafb5334cd4e256c662e5ee6303b1b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 16:00:41 2021 +0200 comment commit b9d58e3faf5b60ad4f5f65454b454ff52deb5eaa Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:55:58 2021 +0200 impossible to get CPU freq on M1 apparently commit 66072711c24b2694c4a0054c58829095ed97ada2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:33:43 2021 +0200 detect full commit 6bb0e930a2c44b4fb7d0d02a40f210fa12fdc657 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:38:46 2021 +0200 CPU freq in GHz commit a5f10f1a0ff9d10fa8d9d3038aa160b2380aa294 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:13:18 2021 +0200 check array length commit 155c848b97e1385bd29eaba91a87ecfb1d846bf7 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 15:05:20 2021 +0200 switch to other way to get CPU freq (still does not work) commit cf51ba2ebe88dddd943040ced484581dc260c3c8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:45:44 2021 +0200 remove some warnings commit 775dff5f72b0631bba0ed01d72374d8c1d1cd059 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:16:45 2021 +0200 fix link commit 8c67967775fb98bda80eee40cb6833a00bfb93a1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:16:38 2021 +0200 reduce diff more commit 70b47d2ca8a7e0927cf9613e8fe776d2405f60ee Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 14:10:23 2021 +0200 reduce diff with main branch commit ca9cb48054c5850cbb3c23d368e04644a1885de0 Merge: d0c6c0a c66b46f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 13:49:20 2021 +0200 Merge remote-tracking branch 'origin/main' into OSX # Conflicts: # Makefile # src/osx/btop_collect.cpp commit c66b46f850d31c100226e519c55b39df9129aeb8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 13:41:57 2021 +0200 battery state via CoreFoundation commit d0c6c0a362d8dc4f76e2901d7b406a70d8a69b6b Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:51:36 2021 +0200 all disks + load averages commit ca67526dc175dba7d98193a6462e70ef1acab194 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:33:55 2021 +0200 show all disks commit 56119f99a95ca541d6ab744a9ded54c84e0a3184 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:17:41 2021 +0200 procs sorting/filtering commit 8d86011d72a07b3f86f6b525b026b805667a3172 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:42:17 2021 +0200 battery states commit a9b64d62e4abf96fe3edcfa660871caef2041d0f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:24:59 2021 +0200 battery hack works on M1 commit ce5103114246f5549017ef4823442a0ea916e1dd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:18:22 2021 +0200 ugly hack to get battery commit d5e6725c6cd6973cc75dfe2993892e1c25ac8d38 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 22:42:42 2021 +0200 CPU stuff commit 5c02bd8c8380c5c74837b982987b7bf31103245f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 21:25:42 2021 +0200 network commit d5da9d49835cdb23ad5830c000e1b93fcb8f46fd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 15:43:05 2021 +0200 correct cached size commit 5f11aba504254d86ed9a2319967590d50988e16f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 12:03:48 2021 +0200 vm stats from syscall + swap commit 776fc968529e8e7e38fc3168c83b2727198722ad Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:48:07 2021 +0200 seems to work indeed commit 7b40e2835a085bfe0d5eb40f367a1ed50353e4d9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:46:14 2021 +0200 allow override optimization flag commit 005ea24e4c9bcc6608671a0635126bf10bdece34 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:09:24 2021 +0200 update Makefile commit af8cec9debac328645f0f4e2f136e4572d88332e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:32:55 2021 +0200 some more params commit 7ebe4f7594599ccafbf72a004ce37f965549f64d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:15:55 2021 +0200 show more disks commit e50a56394a3702b6616d03694f5d23a5f7ba2f1c Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 14:52:56 2021 +0200 disks show something commit 6497a8c2021b67057dfed26488aec0d82e919a90 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 09:15:35 2021 +0200 reformat commit 28e152b80c07c1fb9a4049cca8510f8bdc31adbb Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 23:21:13 2021 +0200 decrease diff with upstream commit 40da88e9ca91f3db540b63b15da5bc34dc9175e9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:56:14 2021 +0200 try to get disks to show commit eaf2bb56a503fd2bf3787bfd90b5bc8640b7d628 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:42:01 2021 +0200 don't crash on deque::back() commit f66b6f712c361fafbe6d0cfd8f8c0838dc1bb4d2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:21 2021 +0200 cpu freq, name & process uid/name commit 34a8a61f4de964d3137637b045be8738c4b1b6e5 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:46:11 2021 +0200 basic process info commit 29bb2dcc5fcc6b946511068f036590c18fb459ce Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:45:39 2021 +0200 initialize mutex (needed on macos apparently and not on linux) commit fb5970b0005793d760e652348d6acc30fb570f70 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:53:41 2021 +0200 comment commit 49d16cdddd56ba5631269eb2ffbec87d9f36f81e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:51:29 2021 +0200 extract delimiters commit 3db9d6647650bd836201b8150e320a7fbf28e3c2 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:28 2021 +0200 first infos on macos: memory used & free commit f8acb2f8542429677116799ddb5f442488cf3f4f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Sep 28 23:37:03 2021 +0200 make it compile on macos (M1 - arm64). Does not run though commit bbba17cd35248e4e9ec9bfc1b113758cfcffde1f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:51:36 2021 +0200 all disks + load averages commit 548203e93dfaf3ec9f24086bee08aac85891c4df Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 10:33:55 2021 +0200 show all disks commit 0ab2be39857fb3dcdb13b49bc9155f17c7d82a4e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Oct 6 00:17:41 2021 +0200 procs sorting/filtering commit 096104c90b571e931a3a7d9c813dbfc9aa47e212 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:42:17 2021 +0200 battery states commit 0ad93684c2a72293b23d6a2163c9ec51b499dfa3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:24:59 2021 +0200 battery hack works on M1 commit c75b0f1cea34e6c4c70332ba7e2572ec9b70deef Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 23:18:22 2021 +0200 ugly hack to get battery commit 600b4f72b3bbbcd85bf5d148942bce7be8cf0b72 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 22:42:42 2021 +0200 CPU stuff commit 4eb812d52c6e179ae386df0156021d7c35cbe5a3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 21:25:42 2021 +0200 network commit 899be68a78270216bfdcca5f0c87668a87c8792f Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 15:43:05 2021 +0200 correct cached size commit a1c7f935e3a5661688c0de1ad3226f7bc43b9979 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 12:03:48 2021 +0200 vm stats from syscall + swap commit bd1050a7404f9766a0125523c868a27d5cfac8e8 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:48:07 2021 +0200 seems to work indeed commit 5094b73758ee88617e8d5ce876211e1efa298769 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:46:14 2021 +0200 allow override optimization flag commit 8811270332bc2276cd18c1116f4d3c2d64a6f721 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Oct 5 10:09:24 2021 +0200 update Makefile commit 42f966f448b9ad571db7849dc8fd525e0fe72309 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:32:55 2021 +0200 some more params commit c1e6d6a62e2810f80fac372e666ec169540b0591 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 15:15:55 2021 +0200 show more disks commit 50fcdaa8543f717bf36146cfa38636fd39009f23 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 14:52:56 2021 +0200 disks show something commit 264bf2d7da0e3fabb5987cddee73762e52170a51 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Mon Oct 4 09:15:35 2021 +0200 reformat commit 1fd625086ba42e9440c463ae940563d934b8b5c3 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 23:21:13 2021 +0200 decrease diff with upstream commit 17f9f3703c1dd52a86176131a2239cd52ee285bd Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:56:14 2021 +0200 try to get disks to show commit 8462ae6431fcfe1985d1bbb4404452ddc03cc1de Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:42:01 2021 +0200 don't crash on deque::back() commit 78bce5b5a6c1c0f3b38f802acad49ec2e32482d6 Merge: 53e379d f9505a4 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:34 2021 +0200 Merge branch 'aristocratos:main' into main commit 53e379d74dffe2282b089450728501b51d13d199 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 22:08:21 2021 +0200 cpu freq, name & process uid/name commit 2a44b307ef9e947c1007a86988876668a5731e64 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:46:11 2021 +0200 basic process info commit 66534eb5b50753217687de0414d390bcb2a14cf1 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sun Oct 3 21:45:39 2021 +0200 initialize mutex (needed on macos apparently and not on linux) commit 0983917f26948d83fd8da103903ec99f88058d87 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:53:41 2021 +0200 comment commit 9732507248b30139d4af54615945c0b4737cff7d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:51:29 2021 +0200 extract delimiters commit 6e704ce8387041c33022459fb6a084362f82a72c Merge: fe4db7c 7bfbd83 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:43 2021 +0200 Merge branch 'main' of github.com:joske/btop commit fe4db7c16cd349053385eda62e9f2df2e7344d3d Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Sat Oct 2 23:48:28 2021 +0200 first infos on macos: memory used & free commit 7bfbd83a476c8cbe3b74e22b1e44f201026bf9d1 Merge: 8c8139b a15f961 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Oct 1 17:05:26 2021 +0200 Merge branch 'aristocratos:main' into main commit 8c8139bd1df0849061b5e1425a3138d5f45ec149 Merge: 679d21c a246c09 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 21:50:00 2021 +0200 Merge branch 'aristocratos:main' into main commit 679d21cd223b1928e8dde95cac25e8bfb412bedf Merge: 4c70c5b a49b8f9 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 20:23:34 2021 +0200 Merge branch 'aristocratos:main' into main commit 4c70c5bdd98bfcc0ae9d9d9e8e3713dc8af71d03 Merge: 84a9746 c70667e Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Sep 29 08:30:05 2021 +0200 Merge branch 'aristocratos:main' into main commit 84a974695afaadc53d1d8576ea66255166ede482 Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Tue Sep 28 23:37:03 2021 +0200 make it compile on macos (M1 - arm64). Does not run though
2022-01-12 00:04:26 +01:00
#endif
2021-08-10 20:20:33 +02:00
#include <thread>
2021-05-19 23:21:56 +02:00
#include <numeric>
#include <ranges>
2021-05-22 02:13:56 +02:00
#include <unistd.h>
#include <cmath>
2021-06-19 22:48:31 +02:00
#include <iostream>
#include <exception>
#include <tuple>
#include <regex>
#include <chrono>
2021-11-27 17:38:29 +01:00
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#include <mach-o/dyld.h>
#include <limits.h>
2021-11-27 17:38:29 +01:00
#endif
2021-05-23 22:25:07 +02:00
2021-06-20 00:49:13 +02:00
#include <btop_shared.hpp>
2021-06-19 22:48:31 +02:00
#include <btop_tools.hpp>
#include <btop_config.hpp>
#include <btop_input.hpp>
#include <btop_theme.hpp>
#include <btop_draw.hpp>
#include <btop_menu.hpp>
2021-05-08 14:56:48 +02:00
2022-10-02 23:29:05 +02:00
using std::atomic;
using std::cout;
using std::endl;
using std::endl;
using std::flush;
using std::min;
using std::string;
using std::string_view;
using std::to_string;
using std::vector;
2021-07-21 03:17:34 +02:00
namespace fs = std::filesystem;
namespace rng = std::ranges;
2022-10-02 23:29:05 +02:00
2021-07-21 03:17:34 +02:00
using namespace Tools;
using namespace std::chrono_literals;
2022-10-02 23:29:05 +02:00
using namespace std::literals;
2021-07-21 03:17:34 +02:00
namespace Global {
2021-07-21 03:17:34 +02:00
const vector<array<string, 2>> Banner_src = {
{"#E62525", "██████╗ ████████╗ ██████╗ ██████╗"},
{"#CD2121", "██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗ ██╗ ██╗"},
{"#B31D1D", "██████╔╝ ██║ ██║ ██║██████╔╝ ██████╗██████╗"},
{"#9A1919", "██╔══██╗ ██║ ██║ ██║██╔═══╝ ╚═██╔═╝╚═██╔═╝"},
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
};
2022-11-06 22:36:34 +01:00
const string Version = "1.2.13";
2021-05-06 20:32:03 +02:00
2021-07-21 03:17:34 +02:00
int coreCount;
string overlay;
string clock;
string bg_black = "\x1b[0;40m";
string fg_white = "\x1b[1;97m";
string fg_green = "\x1b[1;92m";
string fg_red = "\x1b[0;91m";
uid_t real_uid, set_uid;
fs::path self_path;
string exit_error_msg;
atomic<bool> thread_exception (false);
2022-10-02 23:29:05 +02:00
bool debuginit{}; // defaults to false
bool debug{}; // defaults to false
bool utf_force{}; // defaults to false
2021-05-29 02:32:36 +02:00
uint64_t start_time;
atomic<bool> resized (false);
atomic<bool> quitting (false);
2021-11-08 20:35:16 +01:00
atomic<bool> should_quit (false);
atomic<bool> should_sleep (false);
atomic<bool> _runner_started (false);
2022-10-02 23:29:05 +02:00
bool arg_tty{}; // defaults to false
bool arg_low_color{}; // defaults to false
int arg_preset = -1;
2021-05-08 14:56:48 +02:00
}
2021-05-06 20:32:03 +02:00
2021-05-08 14:56:48 +02:00
//* A simple argument parser
2021-07-21 03:17:34 +02:00
void argumentParser(const int& argc, char **argv) {
2021-05-08 02:38:51 +02:00
for(int i = 1; i < argc; i++) {
const string argument = argv[i];
if (is_in(argument, "-h", "--help")) {
2021-09-18 17:33:02 +02:00
cout << "usage: btop [-h] [-v] [-/+t] [-p <id>] [--utf-force] [--debug]\n\n"
<< "optional arguments:\n"
2021-06-21 22:52:55 +02:00
<< " -h, --help show this help message and exit\n"
<< " -v, --version show version info and exit\n"
<< " -lc, --low-color disable truecolor, converts 24-bit colors to 256-color\n"
<< " -t, --tty_on force (ON) tty mode, max 16 colors and tty friendly graph symbols\n"
<< " +t, --tty_off force (OFF) tty mode\n"
2021-09-18 20:31:47 +02:00
<< " -p, --preset <id> start with preset, integer value between 0-9\n"
<< " --utf-force force start even if no UTF-8 locale was detected\n"
<< " --debug start in DEBUG mode: shows microsecond timer for information collect\n"
<< " and screen draw functions and sets loglevel to DEBUG\n"
<< endl;
2021-05-08 02:38:51 +02:00
exit(0);
2021-05-29 02:32:36 +02:00
}
2021-09-12 15:58:23 +02:00
else if (is_in(argument, "-v", "--version")) {
2021-07-21 03:17:34 +02:00
cout << "btop version: " << Global::Version << endl;
exit(0);
}
else if (is_in(argument, "-lc", "--low-color")) {
2021-07-21 03:17:34 +02:00
Global::arg_low_color = true;
}
else if (is_in(argument, "-t", "--tty_on")) {
Config::set("tty_mode", true);
Global::arg_tty = true;
}
else if (is_in(argument, "+t", "--tty_off")) {
Config::set("tty_mode", false);
Global::arg_tty = true;
}
else if (is_in(argument, "-p", "--preset")) {
if (++i >= argc) {
cout << "ERROR: Preset option needs an argument." << endl;
exit(1);
}
else if (const string val = argv[i]; isint(val) and val.size() == 1) {
Global::arg_preset = std::clamp(stoi(val), 0, 9);
}
else {
cout << "ERROR: Preset option only accepts an integer value between 0-9." << endl;
exit(1);
}
}
2021-07-21 03:17:34 +02:00
else if (argument == "--utf-force")
Global::utf_force = true;
else if (argument == "--debug")
Global::debug = true;
2021-05-29 02:32:36 +02:00
else {
2021-05-08 02:38:51 +02:00
cout << " Unknown argument: " << argument << "\n" <<
" Use -h or --help for help." << endl;
exit(1);
}
}
}
2021-07-18 18:04:49 +02:00
//* Handler for SIGWINCH and general resizing events, does nothing if terminal hasn't been resized unless force=true
void term_resize(bool force) {
static atomic<bool> resizing (false);
if (Input::polling) {
Global::resized = true;
Input::interrupt = true;
return;
}
atomic_lock lck(resizing, true);
if (auto refreshed = Term::refresh(true); refreshed or force) {
2021-07-18 18:04:49 +02:00
if (force and refreshed) force = false;
}
else return;
static const array<string, 4> all_boxes = {"cpu", "mem", "net", "proc"};
2021-08-10 20:20:33 +02:00
Global::resized = true;
if (Runner::active) Runner::stop();
Term::refresh();
Config::unlock();
auto boxes = Config::getS("shown_boxes");
auto min_size = Term::get_min_size(boxes);
while (not force or (Term::width < min_size.at(0) or Term::height < min_size.at(1))) {
sleep_ms(100);
if (Term::width < min_size.at(0) or Term::height < min_size.at(1)) {
cout << Term::clear << Global::bg_black << Global::fg_white << Mv::to((Term::height / 2) - 2, (Term::width / 2) - 11)
<< "Terminal size too small:" << Mv::to((Term::height / 2) - 1, (Term::width / 2) - 10)
<< " Width = " << (Term::width < min_size.at(1) ? Global::fg_red : Global::fg_green) << Term::width
<< Global::fg_white << " Height = " << (Term::height < min_size.at(0) ? Global::fg_red : Global::fg_green) << Term::height
<< Mv::to((Term::height / 2) + 1, (Term::width / 2) - 12) << Global::fg_white
<< "Needed for current config:" << Mv::to((Term::height / 2) + 2, (Term::width / 2) - 10)
<< "Width = " << min_size.at(0) << " Height = " << min_size.at(1) << flush;
bool got_key = false;
for (; not Term::refresh() and not got_key; got_key = Input::poll(10));
if (got_key) {
auto key = Input::get();
if (key == "q")
2021-11-14 01:23:12 +01:00
clean_quit(0);
else if (is_in(key, "1", "2", "3", "4")) {
Config::current_preset = -1;
Config::toggle_box(all_boxes.at(std::stoi(key) - 1));
boxes = Config::getS("shown_boxes");
}
}
min_size = Term::get_min_size(boxes);
}
else if (not Term::refresh()) break;
}
Input::interrupt = true;
}
//* Exit handler; stops threads, restores terminal and saves config changes
2021-08-10 20:20:33 +02:00
void clean_quit(int sig) {
2021-06-02 21:33:26 +02:00
if (Global::quitting) return;
Global::quitting = true;
Runner::stop();
if (Global::_runner_started) {
2021-11-13 21:19:18 +01:00
#ifdef __APPLE__
if (pthread_join(Runner::runner_id, NULL) != 0) {
2022-01-16 14:19:31 +01:00
Logger::warning("Failed to join _runner thread on exit!");
2021-11-13 21:19:18 +01:00
pthread_cancel(Runner::runner_id);
}
#else
struct timespec ts;
ts.tv_sec = 5;
if (pthread_timedjoin_np(Runner::runner_id, NULL, &ts) != 0) {
2022-01-16 14:19:31 +01:00
Logger::warning("Failed to join _runner thread on exit!");
pthread_cancel(Runner::runner_id);
}
2021-11-13 21:19:18 +01:00
#endif
}
2021-08-10 20:20:33 +02:00
2021-06-09 19:47:49 +02:00
Config::write();
2021-08-03 23:47:46 +02:00
2021-08-10 20:20:33 +02:00
if (Term::initialized) {
Input::clear();
2021-08-10 20:20:33 +02:00
Term::restore();
}
if (not Global::exit_error_msg.empty()) {
sig = 1;
Logger::error(Global::exit_error_msg);
std::cerr << Global::fg_red << "ERROR: " << Global::fg_white << Global::exit_error_msg << Fx::reset << endl;
}
Logger::info("Quitting! Runtime: " + sec_to_dhms(time_s() - Global::start_time));
const auto excode = (sig != -1 ? sig : 0);
2021-12-29 13:47:48 +01:00
#ifdef __APPLE__
_Exit(excode);
#else
quick_exit(excode);
2021-11-13 21:19:18 +01:00
#endif
2021-06-09 19:47:49 +02:00
}
//* Handler for SIGTSTP; stops threads, restores terminal and sends SIGSTOP
2021-07-21 03:17:34 +02:00
void _sleep() {
Runner::stop();
Term::restore();
2021-06-09 19:47:49 +02:00
std::raise(SIGSTOP);
}
//* Handler for SIGCONT; re-initialize terminal and force a resize event
2021-07-21 03:17:34 +02:00
void _resume() {
2021-06-09 19:47:49 +02:00
Term::init();
2021-07-18 18:04:49 +02:00
term_resize(true);
2021-06-02 21:33:26 +02:00
}
void _exit_handler() {
clean_quit(-1);
}
2021-06-02 21:33:26 +02:00
2021-07-21 03:17:34 +02:00
void _signal_handler(const int sig) {
2021-06-09 19:47:49 +02:00
switch (sig) {
case SIGINT:
2021-11-08 20:35:16 +01:00
if (Runner::active) {
Global::should_quit = true;
Runner::stopping = true;
Input::interrupt = true;
}
else {
clean_quit(0);
}
2021-06-09 19:47:49 +02:00
break;
case SIGTSTP:
2021-11-08 20:35:16 +01:00
if (Runner::active) {
Global::should_sleep = true;
Runner::stopping = true;
Input::interrupt = true;
}
else {
_sleep();
}
2021-06-09 19:47:49 +02:00
break;
case SIGCONT:
_resume();
break;
case SIGWINCH:
2021-07-18 18:04:49 +02:00
term_resize();
2021-06-09 19:47:49 +02:00
break;
}
}
2021-07-21 03:17:34 +02:00
//* Manages secondary thread for collection and drawing of boxes
namespace Runner {
atomic<bool> active (false);
atomic<bool> stopping (false);
2021-08-10 20:20:33 +02:00
atomic<bool> waiting (false);
2021-09-17 14:25:54 +02:00
atomic<bool> redraw (false);
atomic<bool> coreNum_reset (false);
//* Setup semaphore for triggering thread to do work
#if __GNUC__ < 11
#include <semaphore.h>
sem_t do_work;
inline void thread_sem_init() { sem_init(&do_work, 0, 0); }
inline void thread_wait() { sem_wait(&do_work); }
inline void thread_trigger() { sem_post(&do_work); }
#else
#include <semaphore>
std::binary_semaphore do_work(0);
inline void thread_sem_init() { ; }
inline void thread_wait() { do_work.acquire(); }
inline void thread_trigger() { do_work.release(); }
#endif
//* RAII wrapper for pthread_mutex locking
class thread_lock {
pthread_mutex_t& pt_mutex;
public:
int status;
2022-10-02 23:29:05 +02:00
thread_lock(pthread_mutex_t& mtx) : pt_mutex(mtx) {
pthread_mutex_init(&pt_mutex, NULL);
status = pthread_mutex_lock(&pt_mutex);
}
~thread_lock() {
if (status == 0)
pthread_mutex_unlock(&pt_mutex);
}
};
//* Wrapper for raising priviliges when using SUID bit
class gain_priv {
int status = -1;
public:
gain_priv() {
2022-10-02 23:29:05 +02:00
if (Global::real_uid != Global::set_uid)
this->status = seteuid(Global::set_uid);
}
~gain_priv() {
2022-10-02 23:29:05 +02:00
if (status == 0)
status = seteuid(Global::real_uid);
}
};
string output;
2021-09-17 14:25:54 +02:00
string empty_bg;
2022-10-02 23:29:05 +02:00
bool pause_output{}; // defaults to false
2021-08-03 23:47:46 +02:00
sigset_t mask;
pthread_t runner_id;
2021-08-10 20:20:33 +02:00
pthread_mutex_t mtx;
enum debug_actions {
collect_begin,
draw_begin,
draw_done
};
enum debug_array {
collect,
draw
};
string debug_bg;
unordered_flat_map<string, array<uint64_t, 2>> debug_times;
2021-08-03 23:47:46 +02:00
struct runner_conf {
vector<string> boxes;
bool no_update;
bool force_redraw;
2021-09-12 15:58:23 +02:00
bool background_update;
string overlay;
string clock;
2021-08-03 23:47:46 +02:00
};
struct runner_conf current_conf;
void debug_timer(const char* name, const int action) {
switch (action) {
case collect_begin:
debug_times[name].at(collect) = time_micros();
return;
case draw_begin:
debug_times[name].at(draw) = time_micros();
debug_times[name].at(collect) = debug_times[name].at(draw) - debug_times[name].at(collect);
debug_times["total"].at(collect) += debug_times[name].at(collect);
return;
case draw_done:
debug_times[name].at(draw) = time_micros() - debug_times[name].at(draw);
debug_times["total"].at(draw) += debug_times[name].at(draw);
return;
}
}
//? ------------------------------- Secondary thread: async launcher and drawing ----------------------------------
2022-10-02 23:29:05 +02:00
void * _runner(void *) {
2021-11-08 20:35:16 +01:00
//? Block some signals in this thread to avoid deadlock from any signal handlers trying to stop this thread
sigemptyset(&mask);
2021-11-08 20:35:16 +01:00
// sigaddset(&mask, SIGINT);
// sigaddset(&mask, SIGTSTP);
sigaddset(&mask, SIGWINCH);
sigaddset(&mask, SIGTERM);
2021-08-03 23:47:46 +02:00
pthread_sigmask(SIG_BLOCK, &mask, NULL);
//? pthread_mutex_lock to lock thread and monitor health from main thread
thread_lock pt_lck(mtx);
if (pt_lck.status != 0) {
Global::exit_error_msg = "Exception in runner thread -> pthread_mutex_lock error id: " + to_string(pt_lck.status);
Global::thread_exception = true;
Input::interrupt = true;
stopping = true;
}
//* ----------------------------------------------- THREAD LOOP -----------------------------------------------
while (not Global::quitting) {
thread_wait();
atomic_wait_for(active, true, 5000);
if (active) {
Global::exit_error_msg = "Runner thread failed to get active lock!";
Global::thread_exception = true;
Input::interrupt = true;
stopping = true;
}
if (stopping or Global::resized) {
sleep_ms(1);
continue;
}
2021-09-17 14:25:54 +02:00
//? Atomic lock used for blocking non thread-safe actions in main thread
atomic_lock lck(active);
//? Set effective user if SUID bit is set
gain_priv powers{};
auto& conf = current_conf;
//! DEBUG stats
if (Global::debug) {
2022-10-02 23:29:05 +02:00
if (debug_bg.empty() or redraw)
Runner::debug_bg = Draw::createBox(2, 2, 32, 8, "", true, "debug");
debug_times.clear();
debug_times["total"] = {0, 0};
}
output.clear();
//* Run collection and draw functions for all boxes
try {
2021-11-08 19:29:02 +01:00
//? CPU
if (v_contains(conf.boxes, "cpu")) {
try {
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("cpu", collect_begin);
//? Start collect
2021-11-08 19:29:02 +01:00
auto cpu = Cpu::collect(conf.no_update);
if (coreNum_reset) {
coreNum_reset = false;
Cpu::core_mapping = Cpu::get_core_mapping();
Global::resized = true;
Input::interrupt = true;
continue;
}
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("cpu", draw_begin);
//? Draw box
2021-11-08 19:29:02 +01:00
if (not pause_output) output += Cpu::draw(cpu, conf.force_redraw, conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("cpu", draw_done);
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
throw std::runtime_error("Cpu:: -> " + string{e.what()});
}
}
2021-11-08 19:29:02 +01:00
//? MEM
if (v_contains(conf.boxes, "mem")) {
try {
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("mem", collect_begin);
//? Start collect
2021-11-08 19:29:02 +01:00
auto mem = Mem::collect(conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("mem", draw_begin);
//? Draw box
2021-11-08 19:29:02 +01:00
if (not pause_output) output += Mem::draw(mem, conf.force_redraw, conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("mem", draw_done);
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
throw std::runtime_error("Mem:: -> " + string{e.what()});
}
}
2021-11-08 19:29:02 +01:00
//? NET
if (v_contains(conf.boxes, "net")) {
try {
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("net", collect_begin);
//? Start collect
2021-11-08 19:29:02 +01:00
auto net = Net::collect(conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("net", draw_begin);
//? Draw box
2021-11-08 19:29:02 +01:00
if (not pause_output) output += Net::draw(net, conf.force_redraw, conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("net", draw_done);
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
throw std::runtime_error("Net:: -> " + string{e.what()});
}
}
2021-11-08 19:29:02 +01:00
//? PROC
if (v_contains(conf.boxes, "proc")) {
try {
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("proc", collect_begin);
//? Start collect
2021-11-08 19:29:02 +01:00
auto proc = Proc::collect(conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("proc", draw_begin);
//? Draw box
2021-11-08 19:29:02 +01:00
if (not pause_output) output += Proc::draw(proc, conf.force_redraw, conf.no_update);
2021-11-08 19:29:02 +01:00
if (Global::debug) debug_timer("proc", draw_done);
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
throw std::runtime_error("Proc:: -> " + string{e.what()});
}
}
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
Global::exit_error_msg = "Exception in runner thread -> " + string{e.what()};
Global::thread_exception = true;
Input::interrupt = true;
stopping = true;
}
if (stopping) {
continue;
}
2021-09-17 14:25:54 +02:00
if (redraw or conf.force_redraw) {
empty_bg.clear();
redraw = false;
}
2021-09-12 15:58:23 +02:00
if (not pause_output) output += conf.clock;
if (not conf.overlay.empty() and not conf.background_update) pause_output = true;
2021-09-17 14:25:54 +02:00
if (output.empty() and not pause_output) {
if (empty_bg.empty()) {
const int x = Term::width / 2 - 10, y = Term::height / 2 - 10;
output += Term::clear;
empty_bg += Draw::banner_gen(y, 0, true)
+ Mv::to(y+6, x) + Theme::c("title") + Fx::b + "No boxes shown!"
+ Mv::to(y+8, x) + Theme::c("hi_fg") + "1" + Theme::c("main_fg") + " | Show CPU box"
+ Mv::to(y+9, x) + Theme::c("hi_fg") + "2" + Theme::c("main_fg") + " | Show MEM box"
+ Mv::to(y+10, x) + Theme::c("hi_fg") + "3" + Theme::c("main_fg") + " | Show NET box"
+ Mv::to(y+11, x) + Theme::c("hi_fg") + "4" + Theme::c("main_fg") + " | Show PROC box"
+ Mv::to(y+12, x-2) + Theme::c("hi_fg") + "esc" + Theme::c("main_fg") + " | Show menu"
+ Mv::to(y+13, x) + Theme::c("hi_fg") + "q" + Theme::c("main_fg") + " | Quit";
}
output += empty_bg;
}
2021-09-12 15:58:23 +02:00
//! DEBUG stats -->
2021-09-12 15:58:23 +02:00
if (Global::debug and not Menu::active) {
output += debug_bg + Theme::c("title") + Fx::b + ljust(" Box", 9) + ljust("Collect μs", 12, true) + ljust("Draw μs", 9, true) + Theme::c("main_fg") + Fx::ub;
for (const string name : {"cpu", "mem", "net", "proc", "total"}) {
if (not debug_times.contains(name)) debug_times[name] = {0,0};
const auto& [time_collect, time_draw] = debug_times.at(name);
if (name == "total") output += Fx::b;
output += Mv::l(29) + Mv::d(1) + ljust(name, 8) + ljust(to_string(time_collect), 12) + ljust(to_string(time_draw), 9);
}
}
2021-07-21 03:17:34 +02:00
//? If overlay isn't empty, print output without color and then print overlay on top
cout << Term::sync_start << (conf.overlay.empty()
2021-09-12 15:58:23 +02:00
? output
: (output.empty() ? "" : Fx::ub + Theme::c("inactive_fg") + Fx::uncolor(output)) + conf.overlay)
<< Term::sync_end << flush;
}
//* ----------------------------------------------- THREAD LOOP -----------------------------------------------
2021-08-03 23:47:46 +02:00
pthread_exit(NULL);
}
2021-08-10 20:20:33 +02:00
//? ------------------------------------------ Secondary thread end -----------------------------------------------
//* Runs collect and draw in a secondary thread, unlocks and locks config to update cached values
void run(const string& box, bool no_update, bool force_redraw) {
atomic_wait_for(active, true, 5000);
if (active) {
Logger::error("Stall in Runner thread, restarting!");
active = false;
// exit(1);
pthread_cancel(Runner::runner_id);
if (pthread_create(&Runner::runner_id, NULL, &Runner::_runner, NULL) != 0) {
Global::exit_error_msg = "Failed to re-create _runner thread!";
2021-11-14 01:23:12 +01:00
clean_quit(1);
}
}
if (stopping or Global::resized) return;
if (box == "overlay") {
cout << Term::sync_start << Global::overlay << Term::sync_end << flush;
}
else if (box == "clock") {
cout << Term::sync_start << Global::clock << Term::sync_end << flush;
}
else {
Config::unlock();
Config::lock();
current_conf = {
(box == "all" ? Config::current_boxes : vector{box}),
no_update, force_redraw,
(not Config::getB("tty_mode") and Config::getB("background_update")),
Global::overlay,
Global::clock
};
2021-09-12 15:58:23 +02:00
if (Menu::active and not current_conf.background_update) Global::overlay.clear();
2021-08-03 23:47:46 +02:00
thread_trigger();
atomic_wait_for(active, false, 10);
}
}
//* Stops any work being done in runner thread and checks for thread errors
void stop() {
stopping = true;
2021-08-10 20:20:33 +02:00
int ret = pthread_mutex_trylock(&mtx);
if (ret != EBUSY and not Global::quitting) {
2021-08-10 20:20:33 +02:00
if (active) active = false;
Global::exit_error_msg = "Runner thread died unexpectedly!";
2021-11-14 01:23:12 +01:00
clean_quit(1);
}
else if (ret == EBUSY) {
atomic_wait_for(active, true, 5000);
if (active) {
active = false;
if (Global::quitting) {
return;
}
else {
Global::exit_error_msg = "No response from Runner thread, quitting!";
2021-11-14 01:23:12 +01:00
clean_quit(1);
}
}
thread_trigger();
atomic_wait_for(active, false, 100);
atomic_wait_for(active, true, 100);
2021-08-10 20:20:33 +02:00
}
stopping = false;
}
}
2021-05-09 22:25:41 +02:00
2021-05-08 14:56:48 +02:00
2021-07-21 03:17:34 +02:00
//* --------------------------------------------- Main starts here! ---------------------------------------------------
int main(int argc, char **argv) {
2021-05-06 20:32:03 +02:00
2021-07-21 03:17:34 +02:00
//? ------------------------------------------------ INIT ---------------------------------------------------------
2021-05-06 20:32:03 +02:00
2021-05-29 02:32:36 +02:00
Global::start_time = time_s();
//? Save real and effective userid's and drop priviliges until needed if running with SUID bit set
Global::real_uid = getuid();
Global::set_uid = geteuid();
if (Global::real_uid != Global::set_uid) {
if (seteuid(Global::real_uid) != 0) {
Global::real_uid = Global::set_uid;
Global::exit_error_msg = "Failed to change effective user ID. Unset btop SUID bit to ensure security on this system. Quitting!";
clean_quit(1);
}
}
2021-07-21 03:17:34 +02:00
//? Call argument parser if launched with arguments
2021-05-06 20:32:03 +02:00
if (argc > 1) argumentParser(argc, argv);
2021-07-21 03:17:34 +02:00
//? Setup paths for config, log and user themes
for (const auto& env : {"XDG_CONFIG_HOME", "HOME"}) {
2021-09-26 00:17:39 +02:00
if (std::getenv(env) != NULL and access(std::getenv(env), W_OK) != -1) {
Config::conf_dir = fs::path(std::getenv(env)) / (((string)env == "HOME") ? ".config/btop" : "btop");
break;
}
}
if (Config::conf_dir.empty()) {
cout << "WARNING: Could not get path user HOME folder.\n"
<< "Make sure $XDG_CONFIG_HOME or $HOME environment variables is correctly set to fix this." << endl;
}
else {
2021-06-21 22:52:55 +02:00
if (std::error_code ec; not fs::is_directory(Config::conf_dir) and not fs::create_directories(Config::conf_dir, ec)) {
cout << "WARNING: Could not create or access btop config directory. Logging and config saving disabled.\n"
<< "Make sure $XDG_CONFIG_HOME or $HOME environment variables is correctly set to fix this." << endl;
}
else {
2021-05-29 02:32:36 +02:00
Config::conf_file = Config::conf_dir / "btop.conf";
Logger::logfile = Config::conf_dir / "btop.log";
Theme::user_theme_dir = Config::conf_dir / "themes";
2021-06-21 22:52:55 +02:00
if (not fs::exists(Theme::user_theme_dir) and not fs::create_directory(Theme::user_theme_dir, ec)) Theme::user_theme_dir.clear();
}
}
2021-07-21 03:17:34 +02:00
//? Try to find global btop theme path relative to binary path
#ifdef __linux__
{ std::error_code ec;
Global::self_path = fs::read_symlink("/proc/self/exe", ec).remove_filename();
}
#elif __APPLE__
{
char buf [PATH_MAX];
uint32_t bufsize = PATH_MAX;
if(!_NSGetExecutablePath(buf, &bufsize))
Global::self_path = fs::path(buf).remove_filename();
}
#endif
2021-06-21 22:52:55 +02:00
if (std::error_code ec; not Global::self_path.empty()) {
Theme::theme_dir = fs::canonical(Global::self_path / "../share/btop/themes", ec);
if (ec or not fs::is_directory(Theme::theme_dir) or access(Theme::theme_dir.c_str(), R_OK) == -1) Theme::theme_dir.clear();
}
2021-07-21 03:17:34 +02:00
//? If relative path failed, check two most common absolute paths
2021-05-29 02:32:36 +02:00
if (Theme::theme_dir.empty()) {
for (auto theme_path : {"/usr/local/share/btop/themes", "/usr/share/btop/themes"}) {
if (fs::is_directory(fs::path(theme_path)) and access(theme_path, R_OK) != -1) {
2021-05-29 02:32:36 +02:00
Theme::theme_dir = fs::path(theme_path);
break;
}
}
}
2021-06-13 23:12:11 +02:00
//? Config init
{ vector<string> load_warnings;
Config::load(Config::conf_file, load_warnings);
2021-06-12 18:49:27 +02:00
if (Config::current_boxes.empty()) Config::check_boxes(Config::getS("shown_boxes"));
2021-06-21 22:52:55 +02:00
Config::set("lowcolor", (Global::arg_low_color ? true : not Config::getB("truecolor")));
if (Global::debug) {
Logger::set("DEBUG");
Logger::debug("Starting in DEBUG mode!");
}
else Logger::set(Config::getS("log_level"));
2021-06-12 18:49:27 +02:00
Logger::info("Logger set to " + (Global::debug ? "DEBUG" : Config::getS("log_level")));
2021-06-12 18:49:27 +02:00
for (const auto& err_str : load_warnings) Logger::warning(err_str);
2021-06-12 18:49:27 +02:00
}
2021-05-23 22:25:07 +02:00
2021-07-21 03:17:34 +02:00
//? Try to find and set a UTF-8 locale
2021-09-29 21:24:33 +02:00
if (std::setlocale(LC_ALL, "") != NULL and not s_contains((string)std::setlocale(LC_ALL, ""), ";")
and str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) {
Logger::debug("Using locale " + (string)std::setlocale(LC_ALL, ""));
}
else {
string found;
2022-10-02 23:29:05 +02:00
bool set_failure{}; // defaults to false
2021-09-29 21:24:33 +02:00
for (const auto loc_env : array{"LANG", "LC_ALL"}) {
if (std::getenv(loc_env) != NULL and str_to_upper(s_replace((string)std::getenv(loc_env), "-", "")).ends_with("UTF8")) {
found = std::getenv(loc_env);
if (std::setlocale(LC_ALL, found.c_str()) == NULL) {
set_failure = true;
Logger::warning("Failed to set locale " + found + " continuing anyway.");
}
}
}
if (found.empty()) {
if (setenv("LC_ALL", "", 1) == 0 and setenv("LANG", "", 1) == 0) {
2021-09-25 11:35:50 +02:00
try {
if (const auto loc = std::locale("").name(); not loc.empty() and loc != "*") {
for (auto& l : ssplit(loc, ';')) {
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
2021-09-29 21:24:33 +02:00
found = l.substr(l.find('=') + 1);
if (std::setlocale(LC_ALL, found.c_str()) != NULL) {
break;
2021-09-25 11:35:50 +02:00
}
}
}
2021-07-21 03:17:34 +02:00
}
}
catch (...) { found.clear(); }
2021-07-21 03:17:34 +02:00
}
}
2021-09-25 11:35:50 +02:00
2021-11-27 17:38:29 +01:00
#ifdef __APPLE__
if (found.empty()) {
CFLocaleRef cflocale = CFLocaleCopyCurrent();
CFStringRef id_value = (CFStringRef)CFLocaleGetValue(cflocale, kCFLocaleIdentifier);
auto loc_id = CFStringGetCStringPtr(id_value, kCFStringEncodingUTF8);
CFRelease(cflocale);
std::string cur_locale = (loc_id != nullptr ? loc_id : "");
if (cur_locale.empty()) {
Logger::warning("No UTF-8 locale detected! Some symbols might not display correctly.");
}
else if (std::setlocale(LC_ALL, string(cur_locale + ".UTF-8").c_str()) != NULL) {
Logger::debug("Setting LC_ALL=" + cur_locale + ".UTF-8");
}
else if(std::setlocale(LC_ALL, "en_US.UTF-8") != NULL) {
Logger::debug("Setting LC_ALL=en_US.UTF-8");
}
else {
Logger::warning("Failed to set macos locale, continuing anyway.");
}
}
#else
if (found.empty() and Global::utf_force)
2021-07-21 03:17:34 +02:00
Logger::warning("No UTF-8 locale detected! Forcing start with --utf-force argument.");
else if (found.empty()) {
Global::exit_error_msg = "No UTF-8 locale detected!\nUse --utf-force argument to force start if you're sure your terminal can handle it.";
clean_quit(1);
2021-07-21 03:17:34 +02:00
}
2021-11-27 17:38:29 +01:00
#endif
2021-09-29 21:24:33 +02:00
else if (not set_failure)
Logger::debug("Setting LC_ALL=" + found);
2021-05-23 22:25:07 +02:00
}
2021-05-09 00:18:51 +02:00
//? Initialize terminal and set options
2021-06-21 22:52:55 +02:00
if (not Term::init()) {
Global::exit_error_msg = "No tty detected!\nbtop++ needs an interactive shell to run.";
clean_quit(1);
2021-05-06 20:32:03 +02:00
}
2021-09-26 00:17:39 +02:00
if (Term::current_tty != "unknown") Logger::info("Running on " + Term::current_tty);
2021-06-21 22:52:55 +02:00
if (not Global::arg_tty and Config::getB("force_tty")) {
Config::set("tty_mode", true);
Logger::info("Forcing tty mode: setting 16 color mode and using tty friendly graph symbols");
}
2021-11-13 21:19:18 +01:00
#ifndef __APPLE__
2021-06-21 22:52:55 +02:00
else if (not Global::arg_tty and Term::current_tty.starts_with("/dev/tty")) {
Config::set("tty_mode", true);
Logger::info("Real tty detected: setting 16 color mode and using tty friendly graph symbols");
}
2021-11-13 21:19:18 +01:00
#endif
//? Check for valid terminal dimensions
{
int t_count = 0;
while (Term::width <= 0 or Term::width > 10000 or Term::height <= 0 or Term::height > 10000) {
sleep_ms(10);
Term::refresh();
if (++t_count == 100) {
Global::exit_error_msg = "Failed to get size of terminal!";
clean_quit(1);
}
}
}
2021-07-21 03:17:34 +02:00
//? Platform dependent init and error check
try {
Shared::init();
}
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
Global::exit_error_msg = "Exception in Shared::init() -> " + string{e.what()};
clean_quit(1);
}
2021-06-25 23:58:19 +02:00
2021-07-21 03:17:34 +02:00
//? Update list of available themes and generate the selected theme
2021-06-25 23:58:19 +02:00
Theme::updateThemes();
Theme::setTheme();
2021-05-09 00:18:51 +02:00
//? Setup signal handlers for CTRL-C, CTRL-Z, resume and terminal resize
std::atexit(_exit_handler);
std::signal(SIGINT, _signal_handler);
std::signal(SIGTSTP, _signal_handler);
std::signal(SIGCONT, _signal_handler);
std::signal(SIGWINCH, _signal_handler);
//? Start runner thread
Runner::thread_sem_init();
if (pthread_create(&Runner::runner_id, NULL, &Runner::_runner, NULL) != 0) {
Global::exit_error_msg = "Failed to create _runner thread!";
2021-11-14 01:23:12 +01:00
clean_quit(1);
}
else {
Global::_runner_started = true;
}
2021-07-21 03:17:34 +02:00
//? Calculate sizes of all boxes
Config::presetsValid(Config::getS("presets"));
if (Global::arg_preset >= 0) {
Config::current_preset = min(Global::arg_preset, (int)Config::preset_list.size() - 1);
Config::apply_preset(Config::preset_list.at(Config::current_preset));
}
2021-05-08 02:38:51 +02:00
{
const auto [x, y] = Term::get_min_size(Config::getS("shown_boxes"));
if (Term::height < y or Term::width < x) {
term_resize(true);
Global::resized = false;
Input::interrupt = false;
}
}
Draw::calcSizes();
//? Print out box outlines
2021-07-21 03:17:34 +02:00
cout << Term::sync_start << Cpu::box << Mem::box << Net::box << Proc::box << Term::sync_end << flush;
2021-05-23 22:25:07 +02:00
2021-07-21 03:17:34 +02:00
//? ------------------------------------------------ MAIN LOOP ----------------------------------------------------
2021-05-09 22:25:41 +02:00
2021-07-21 03:17:34 +02:00
uint64_t update_ms = Config::getI("update_ms");
auto future_time = time_ms();
try {
2021-07-18 18:04:49 +02:00
while (not true not_eq not false) {
2021-07-21 03:17:34 +02:00
//? Check for exceptions in secondary thread and exit with fail signal if true
2021-11-14 01:23:12 +01:00
if (Global::thread_exception) clean_quit(1);
else if (Global::should_quit) clean_quit(0);
2021-11-08 20:35:16 +01:00
else if (Global::should_sleep) { Global::should_sleep = false; _sleep(); }
2021-07-18 18:04:49 +02:00
//? Make sure terminal size hasn't changed (in case of SIGWINCH not working properly)
term_resize(Global::resized);
2021-05-27 22:29:36 +02:00
2021-08-10 20:20:33 +02:00
//? Trigger secondary thread to redraw if terminal has been resized
2021-07-18 18:04:49 +02:00
if (Global::resized) {
2021-08-10 20:20:33 +02:00
Draw::calcSizes();
2021-09-17 14:25:54 +02:00
Draw::update_clock(true);
Global::resized = false;
if (Menu::active) Menu::process();
else Runner::run("all", true, true);
atomic_wait_for(Runner::active, true, 1000);
2021-07-18 18:04:49 +02:00
}
//? Update clock if needed
2021-09-12 15:58:23 +02:00
if (Draw::update_clock() and not Menu::active) {
Runner::run("clock");
}
2021-07-21 03:17:34 +02:00
//? Start secondary collect & draw thread at the interval set by <update_ms> config value
if (time_ms() >= future_time and not Global::resized) {
2021-07-18 18:04:49 +02:00
Runner::run("all");
2021-07-21 03:17:34 +02:00
update_ms = Config::getI("update_ms");
2021-07-18 18:04:49 +02:00
future_time = time_ms() + update_ms;
2021-06-13 23:12:11 +02:00
}
2021-07-21 03:17:34 +02:00
//? Loop over input polling and input action processing
2021-08-10 20:20:33 +02:00
for (auto current_time = time_ms(); current_time < future_time; current_time = time_ms()) {
2021-07-21 03:17:34 +02:00
2021-08-03 23:47:46 +02:00
//? Check for external clock changes and for changes to the update timer
if (std::cmp_not_equal(update_ms, Config::getI("update_ms"))) {
2021-08-03 23:47:46 +02:00
update_ms = Config::getI("update_ms");
future_time = time_ms() + update_ms;
}
else if (future_time - current_time > update_ms)
2021-07-18 18:04:49 +02:00
future_time = current_time;
2021-07-21 03:17:34 +02:00
//? Poll for input and process any input detected
else if (Input::poll(min((uint64_t)1000, future_time - current_time))) {
if (not Runner::active) Config::unlock();
if (Menu::active) Menu::process(Input::get());
else Input::process(Input::get());
2021-07-21 03:17:34 +02:00
}
//? Break the loop at 1000ms intervals or if input polling was interrupted
else break;
2021-06-13 23:12:11 +02:00
}
2021-07-18 18:04:49 +02:00
}
}
2021-09-12 15:58:23 +02:00
catch (const std::exception& e) {
2022-10-02 23:29:05 +02:00
Global::exit_error_msg = "Exception in main loop -> " + string{e.what()};
2021-11-14 01:23:12 +01:00
clean_quit(1);
}
2021-05-10 23:46:41 +02:00
2021-05-06 20:32:03 +02:00
}