When checking whether an FD is ready for input or output, also check for special situations (error, device/FIFO/pipe hangup and invalid FD) in the poll() implementation of the scheduler. This fixes a CPU consumption bug in waiting for process-ports on Linux (thanks to Mario Goulart for finding the bug).

Signed-off-by: Mario Domenech Goulart <mario.goulart@gmail.com>
Fix mutex-lock! type signature (thanks to Joerg Wittenberger for reporting this bug)

Signed-off-by: Mario Domenech Goulart <mario.goulart@gmail.com>
Remove ##sys#get-argument and simplify get-environment-variable

by using the FFI instead of hand-rolled C functions; deprecated these
underlying C functions This should make the code easier to understand,
more maintainable and reduce bloat. It is also a more structural
approach of preventing security problems like those fixed by
d9f2ad87b42f by using one vetted underlying system; the FFI conversion
procedures.

Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>
Signed-off-by: Peter Bex <peter.bex@xs4all.nl>
setup-download: fix +url-regex+ and deconstruct-url to match urls with path=/ or no path when port number is provided

Without this patch, we get:

(deconstruct-url "http://localhost:8080")
   => (values "http://localhost:8080" 80 "/")

(deconstruct-url "http://localhost:8080/")
   => (values "http://localhost:8080/" 80 "/")

That behavior makes chicken-install request port 80, even if
another port was requested (8080, in the examples).  Also, it
returns host as "http://localhost:8080" instead of "localhost".

This patch makes deconstruct-url correctly handle / and no path
when a port is provided:

(deconstruct-url "http://localhost:8080")
   => (values "localhost" 8080 "/")

(deconstruct-url  "http://localhost:8080/")
   => (values "localhost" 8080 "/")

Signed-off-by: Peter Bex <peter.bex@xs4all.nl>