OpenBSD support

Starting from version 3.3.0 (released just now) psutil officially supports OpenBSD. This was contributed by Landry Breuil and myself in PR-615.

Differences with FreeBSD

As expected, the OpenBSD implementation is very similar to FreeBSD's, so I merged most of it into a single C file (_psutil_bsd.c), with 2 separate files (freebsd.c, openbsd.c) for the parts that differ. Here are the functional differences with FreeBSD:

  • Process.memory_maps() is not implemented. The kernel provides the necessary pieces but I haven't done this yet (hopefully later).
  • Process.num_ctx_switches()'s involuntary field is always 0. kinfo_proc provides this info but it is always set to 0.
  • Process.cpu_affinity() (get and set) is not supported.
  • Process.exe() is determined by inspecting the command line, so it may not always be available (returns None).
  • psutil.swap_memory() sin and sout (swap in and swap out) values are not available, and are therefore always set to 0.
  • psutil.cpu_count(logical=False) always returns None.

As with FreeBSD, Process.open_files() can't return file paths (FreeBSD can sometimes). Otherwise everything is there and I'm satisfied with the result.

Considerations about BSD platforms

psutil has supported FreeBSD since the beginning (year 2009). At the time, it made sense to prefer it as the preferred BSD variant as it's the most popular.

Compared to FreeBSD, OpenBSD appears to be more "minimal", both in terms of kernel facilities and the number of CLI tools available. One thing I particularly appreciate about FreeBSD is that the source code for all CLI tools is available under /usr/src, which was a big help when implementing psutil APIs.

OpenBSD source code is also available, but it uses CVS and I am not sure it includes the source code for all CLI tools.

There are still two more BSD variants worth supporting: NetBSD and DragonFlyBSD (in this order). About a year ago, someone provided a patch adding basic NetBSD support, so that will likely happen sooner or later.

Other enhancements available in this release

The only other enhancement is #558, which allows specifying a different location for the /proc filesystem on Linux.

Discussion

Social

Feeds