Closed donpdonp closed 4 years ago
Im trying to get a list of interfaces using the libc function, after hitting a dead end trying to code it myself, i found this library. When trying to call the same function via the library, it also crashes. Any idea whats going on here?
donp@jewel nimnet $ nim Nim Compiler Version 0.20.0 [Linux: amd64] Compiled at 2019-06-06 donp@jewel nimnet $ nimble install psutil Downloading https://github.com/juancarlospaco/psutil-nim using git Verifying dependencies for psutil@0.5.7 Installing psutil@0.5.7 Prompt: psutil@0.5.7 already exists. Overwrite? [y/N] Answer: y Success: psutil installed successfully. donp@jewel nimnet $ cat ps.nim import psutil echo net_if_addrs() echo boot_time() echo users() donp@jewel nimnet $ nim c ps.nim Hint: used config file '/opt/nim/0.20/config/nim.cfg' [Conf] Hint: system [Processing] Hint: widestrs [Processing] Hint: io [Processing] Hint: ps [Processing] Hint: psutil [Processing] Hint: math [Processing] Hint: bitops [Processing] Hint: macros [Processing] Hint: os [Processing] Hint: strutils [Processing] Hint: parseutils [Processing] Hint: algorithm [Processing] Hint: unicode [Processing] Hint: pathnorm [Processing] Hint: osseps [Processing] Hint: posix [Processing] Hint: times [Processing] Hint: options [Processing] Hint: typetraits [Processing] Hint: sequtils [Processing] Hint: tables [Processing] Hint: hashes [Processing] Hint: common [Processing] Hint: nativesockets [Processing] Hint: psutil_posix [Processing] Hint: psutil_linux [Processing] Hint: net [Processing] Hint: sets [Processing] Hint: [Link] Hint: operation successful (46277 lines compiled; 1.237 sec total; 72.125MiB peakmem; Debug Build) [SuccessX] donp@jewel nimnet $ ./ps Traceback (most recent call last) /home/donp/code/nimnet/ps.nim(3) ps /home/donp/.nimble/pkgs/psutil-0.5.7/psutil/psutil_posix.nim(125) net_if_addrs SIGSEGV: Illegal storage access. (Attempt to read from nil?)
https://github.com/juancarlospaco/psutil-nim#troubleshooting It wont work on certain Linuxes, you can use a try except or when or similar construct, but yeah those functions wont work on all Linuxes.
try except
when
Im trying to get a list of interfaces using the libc function, after hitting a dead end trying to code it myself, i found this library. When trying to call the same function via the library, it also crashes. Any idea whats going on here?