Before, in the case of an unknown battery status (which often happens on my Sony VAIO laptop after waking from sleep), the buffer would be unterminated.
(Although, this memmove trick is a bit odd. It would probably be better to remove the memmove's and put a single buffer[1] = '\0'; at the end of the function).
Conky takes process names from /proc/<pid>/stat and it's limited to 16
chars in kernel. That obviously makes top_name_width option to work only
for decreasing name length. To obtain longer names we parse
/proc/<pid>/cmdline.
Not every process has cmdline, so we take both process names and choose
one we want to use. Like this:
- Get process name from /proc/<pid>/stat
- Get process cmdline from /proc/<pid>/cmdline
- Transform cmdline to a bit simpler form(i.e. "/usr/bin/python
/usr/bin/terminator" to "python /usr/bin/terminator"), keeping
the arguments(might be changed easily)
- Choose the one that is longer and use it
== common.cc ==
'result' can be uninitialized.
== conky.cc ==
strcpy()'s overlap: undefined behaviour. memmove()'s one is
defined.
== eve.cc ==
Some simplifications, and there are two leaks:
1. 'mySkill' could be leaked. So, let's make 'skill' point to it instead
of strdup()'ing the buffer.
2. 'output' could be leaked at l.390.
== freebsd.cc ==
Leak of 'freq_sysctl'.
== net_stat.cc ==
free() already null-checks, so we don't need to do it again.
== proc.cc ==
Leak.
Signed-off-by: Pavel Labath <pavelo@centrum.sk>
Sometimes wlan related TEXT causes segment fault, and backtrace shows it's strtok in
iw_get_stats.
I read the code of wireless_tools, which says 'strtok not thread safe, not used in WE-12 and
later' for iw_get_stats. But it need to first check if has_range and then we_version_compiled.
In conky/src/linux.cc, iw_get_stats is called before iw_get_range_info, hence has_range is always
0 in iw_get_stats and strtok is used. I simply move iw_get_range_info before iw_get_stats and no
segfault up to now.
patch by ruikai
curl implements some of the timeouts using alarm(), where the alarm handler longjmp()s back into the
curl code. This is a bad idea in multi-threaded applications, since it is not guaranteed that
SIGALARM will be recieved by the correct thread. Therefore, we instruct curl to avoid using
signals.
Conflicts:
src/ccurl_thread.c
Adds mpd_albumartist support as an object since mpd_artist lists all participating artists of the
current song and not the main album artist.
patch by Sébastien Lavoie-Courchesne
statfs64 ist atm linux specific; wrap statfs around it.
Also cleanup param.h and mount.h including: the assumption in fs.cc
that their presence is a sign of *BSDs is wrong, as they exist in
linux too with different meaning.
Besides presence of mount.h isn't detected in Conky.cmake, so
conditional including mount.h in fs.cc is useless. Is just works
because mount.h and param.h are included in freebsd.h and dragonfly.h
later on. They are unneded in linux.
Just remove conditional including of mount.h and param.h in fs.cc,
conditional wrap statfs64 in proper *BSD header files.
DragonFlyBSD uses pkgsrc package infrastructure, hence the the need
for extra flags.
Cmake pkg_search_module macro sets according <XPREFIX>_LDFLAGS var,
thus the correct way should be to append it to conky_includes and
conky_libs for each extra package needed.
As all pkgsrc packages always install in /usr/pkg, the simplest thing
is to set specific cflags and ldflags at the very beginning.
Conky is btw wip (work in progress) in pkgsrc system, mostly with
NetBSD patches. This is intended as radical workaround (DragonFlyBSD
specific for now) instead of submitting specific patches to pksrc
maintainers.
* process* management left to top.cc
* compile with -Wall -Werror (lots of wasted time for stupid errors)
* unify find_process() and new_process(), as used always together
Signed-off-by: Pavel Labath <pavelo@centrum.sk>
* don't use kvm_* calls, just sysctl (so no suid perm necessary)
* sysctls calls in general aren't thread safe, collapse callbacks
using same sysctls (specifically total/running procs and proc list
ones).
Some sysctls need two calls (first to get size of obj returned,
second to get object self); if different threads use this schema
on same sysctl, weird values are returned (first/second calls
sequence should be serialized).
In general it makes not much sense too having more threads that use
the same sysctl; just get info once and populate all data.
* add DragonFly specific extended uname string ($version in conky.conf)
with git version and signature
Todo:
- top process list logic is old style, use top.cc funcs.
- find a solution for cpu freq
Signed-off-by: Pavel Labath <pavelo@centrum.sk>