SWI-Prolog / packages-clib

Assorted external libraries: processes, sockets, MIME, CGI, etc.
8 stars 19 forks source link

Misleading error message for rlimit/3 #19

Closed wouterbeek closed 7 years ago

wouterbeek commented 7 years ago

The following error message is a bit misleading:

?- [library(rlimit)].
?- rlimit(nofile, _, 5000).
ERROR: error in system call (Invalid argument)
ERROR: In:
ERROR:    [8] clib_rlimit:rlimit(nofile,1024,5000)
ERROR:    [7] <user>

The problem is not that the argument is invalid, but that the OS has a lower hard limit. A better exception would be resource_error/1.

JanWielemaker commented 7 years ago

There is little one can reasonably do. The underlying system call says EINVAL, which can mean a lot of things. We'd have to look around ourselves which is the most likely cause. I think that is way above what one can expect for this rather obscure predicate. And then, should it be a resource_error? A permission_error also makes sense ...

wouterbeek commented 7 years ago

Fair points. The predicate may be somewhat obscure, but it is needed if one uses the RocksDB library.