Commit Diff


commit - 048144dd69faf87abbcb28d9507f744f2aef6018
commit + 29c14c1dfd1d4d884615e219ff3fc6ff7fd49752
blob - 6753a50e89ff13a567e57cff3e604b5503261cc3
blob + 101e1ecc406cb95c551899d5e43b4c720d3edbfb
--- apmtop.c
+++ apmtop.c
@@ -353,6 +353,7 @@ main (int argc, char *argv[])
 
 	// pledge(2) doesn't work, because apmtop(1) needs sysctl(2).
 	unveil ("/usr/share/terminfo", "r");
+	unveil ("/dev/apm", "r");
 	unveil (NULL, NULL);
 
 	memset (&dpy, 0, sizeof (dpy));
@@ -383,6 +384,8 @@ main (int argc, char *argv[])
 	dpy.ncpu = num_cpu ();
 	dpy.cpus = calloc (dpy.ncpu, sizeof (struct cpu_usage));
 	dpy.fd_apm = open ("/dev/apm", O_RDONLY);
+	if (dpy.fd_apm < 0)
+		warn ("failed to open /dev/apm");
 	dpy.running = true;
 	find_sensors ();