Slide: []Talk: Going cross-platform
Presenter: @hisham_hm

PID USER

PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandGoing cross-platform
how htop was made portable
Hisham Muhammad@hisham_hm http://hisham.hm

Slide: [PID USER

2] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Command

About meoriginal author of htop, a project started in 2004
http://hisham.hm/htop/

lead developer of LuaRocks, the package
manager for the Lua
http://luarocks.org/

co-founder of the GoboLinux distribution
http://gobolinux.org/

Slide: [PID USER

3] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

What is htop
an interactive process manager
intended to be “a better top”
by this I originally meant: scrolling!

(versions of top improved a lot since!)

TIME+

CommandSlide: [PID USER

4] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

Hello, htop!

TIME+

CommandSlide: [PID USER

5] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Command

Linux-only
entire logic for gathering process data is basedon the /proc filesystemthat's how top did it too, seemed right

UI was dependent only on the portable libraryncursesso far so good, for many years

Slide: [PID USER

6] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Commandhtop off-Linux
users got htop running on FreeBSD
using linprocfs (a Linux procfs emulation layer)
users sent patches and asked for minor tweaks
for that scenario●happy to merge!

Slide: [PID USER

7] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandBackstory« A wild Mac OS X fork appears! »an ad-hoc port of htop 0.8.2
deleted all Linux-specific codeby the time I took note of it, the codebase haddivergedSlide: [PID USER

8] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandFast-forward a few years
bug reports popping up in htop's bugtracker
old bugs, fixed in htop mainline for years!

it started to get annoying and look badSlide: [PID USER

9] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Command

A fundraiser
summer job: port it to Mac OS X “the right way”
reached 1/3 of its goal
so I decided not to port it to the Mac, but to atleast make htop portableSlide: [PID USER

10] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandMaking it portableby this I mean making it amenable to be ported
so initially I didn't really port it
but I paved the way so that whoever did it,
could do it cleanlySlide: [PID USER

11] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandBreaking Linux dependency the easy way
try to compile it on another OS
set up a VM

first try: FreeBSD
gave up quickly

second try: PC-BSD
path of least resistance for a Linux user!

Slide: [PID USER

12] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandApproaches for multi-platform apps
separate codebases
sometimes it really makes sense: iOS vs. Android

a spaghetti of #ifdefs
sometimes it's the right thing to do

Clean interfaces (APIs) between portable andplatform-specific parts

Slide: [PID USER

13] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%TIME+

Command

Isolated the Linux-specific code
Created two sub-directories
linux/
unsupported/

Slide: [PID USER

14] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

TIME+

Command

Isolated the Linux-specific code
Created two sub-directories
linux/
unsupported/

And, for fun
freebsd/

Slide: [PID USER

15] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

An “OOP” approach
Process.c
Process.h
ProcessList.c
ProcessList.h...
linux/LinuxProcess.cLinuxProcessList.c...

TIME+

CommandSlide: [PID USER

16] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Upload to GitHub and...
unsupported/
linux/
freebsd/

CommandSlide: [PID USER

17] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

TIME+

Upload to GitHub and...
unsupported/
linux/
freebsd/ - merged PRs!

CommandSlide: [PID USER

18] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Upload to GitHub and...
unsupported/
linux/
freebsd/
openbsd/

CommandSlide: [PID USER

19] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

TIME+

Upload to GitHub and...
unsupported/
linux/
freebsd/
openbsd/
darwin/CommandSlide: [PID USER

20] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRI

NI

VIRT

RES

SHR S CPU% MEM%

TIME+

Positive social impact
more, new contributors
always a good thing!

more diverse contributors
OpenBSD people and their security concerns!
anyone wants to port it to NetBSD?
...Cygwin!?

CommandSlide: [PID USER

21] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

Commandhtop 2.0
The code is ready!
http://github.com/hishamhm/htop/
Packages reaching your repositories soon!

Slide: [PID USER

22] Date: 31/01/2016
Talk: Going cross-platform
Presenter: @hisham_hm
PRINI

VIRT

RES

SHR S CPU% MEM%

TIME+

CommandThanks!
All fundraiser contributors!
David Hunt - Darwin support
Martin Misuth (etosan)
Christian Hesse (eworm-de)Michael McConville (mmcco)
Michael Klein (mklein-de)Kang-Che Sung (Explorer09)
and many others who sent in patches and bug reports!!