Commit Graph

7 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 9c7a2e9128
Avoid crashing on SIGPIPE
Under some circumstances, clients could cause SIGPIPE to slcl. Since
this signal was not handled by server.c (i.e., via sigaction(3)), slcl
would crash without any error messages printed to stderr.

In such situation, SIGPIPE should not be usually considered a fatal
error, so it is preferrable to close the connection and keep working.
2023-05-01 04:13:25 +02:00
Xavier Del Campo Romero dc063b90cb
Replace select(2) with poll(2)
select(2) has a number of well-known issues (e.g.: FD_SETSIZE limiting
the maximum amount of file descriptors to watch) that are mostly solved
by poll(2) and thus can be used as a drop-in replacement.
2023-05-01 04:13:16 +02:00
Xavier Del Campo Romero b3ef22ac2a
Define _POSIX_C_SOURCE
This allows using the default compiler defined by make(1) (i.e.,
c99(1)), thus improving POSIX compatibility.
2023-03-24 02:49:11 +01:00
Xavier Del Campo Romero 5e100ff3c1
server.c: Fix wrong size for memcpy(3) 2023-03-08 01:17:34 +01:00
Xavier Del Campo Romero 0954abcf09
server.c: Minor const-correctness improvement 2023-03-07 12:41:03 +01:00
Xavier Del Campo Romero 62bdf9f72f
Fix memory leak on failed realloc(3)
According to C99 §7.20.3.4:

If memory for the new object cannot be allocated, the old object is not
deallocated and its value is unchanged.

Therefore, a temporary pointer must be used to ensure the original
object can still be deallocated should realloc(3) return a null pointer.
2023-03-04 03:03:15 +01:00
Xavier Del Campo Romero d26f046fc9
Initial commit 2023-02-28 01:43:56 +01:00