I have a program that runs linux program as a daemon by loading them with consult and then using http_daemon. It used to work fine but I’m resurrecting it after not using it for a while. I noticed that now http_daemon was throwing an exception but it wouldn’t tell me why in the program’s current form. The program was, in fact, run as daemon, but the calling program (daemon.pl) wasn’t terminating normally. So, I executed it from the top level line by line. When I got to the point where http_daemon is called, something strange happened.
103 ?- consult(apps(‘Accounts’/accounts)).
true.
104 ?- http_daemon([syslog(accounts),pidfile(‘accounts.pid’),port=5001]).
ERROR: 2026-02-21 20:42:35.384 Cannot open port 80. Only root can open ports below 1000.
This explains the exception but not why. A port is opened on 5001 successfully and the routes in the consulted file work fine but the calling program throws this exception and I can’t figure out why.
Thanks, my test of going line by line works fine with your change. Unfortunately, my program always used port(5001) and still throws an exception, so the test wasn’t really valid anyway. I put a line in printing the actual option list passed to http_daemon. This is what I get when starting it:
It doesn’t tell me what the exception is, but I know it’s in http_daemon. Can I use catch/3 to tell me what the exception is? I can’t really see how to do that.
That is not the one you are after. It is raised by halt(0). This causes the stack the be unwound, so all cleanup happens. After the exception reaches the outer-most frame it will do the actual halt.
If it really does not tell you what the exception is, call
?- gtrap(_).
before starting the daemon. That should trap the debugger near the origin of the exception.