1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-29 13:25:43 +03:00

Merge pull request #1422 from keszybz/sd-daemon-mq-badf

sd-daemon: fix return value for sd_is_mq
This commit is contained in:
Lennart Poettering 2015-09-30 22:33:50 +02:00
commit 32c6d387bf
2 changed files with 8 additions and 3 deletions

View File

@ -310,10 +310,15 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
_public_ int sd_is_mq(int fd, const char *path) {
struct mq_attr attr;
assert_return(fd >= 0, -EBADF);
/* Check that the fd is valid */
assert_return(fcntl(fd, F_GETFD) >= 0, -errno);
if (mq_getattr(fd, &attr) < 0)
if (mq_getattr(fd, &attr) < 0) {
if (errno == EBADF)
/* A non-mq fd (or an invalid one, but we ruled that out above) */
return 0;
return -errno;
}
if (path) {
char fpath[PATH_MAX];

View File

@ -3110,7 +3110,7 @@ static int start_special(int argc, char *argv[], void *userdata) {
return r;
} else if (a == ACTION_EXIT && argc > 1) {
uint8_t code = 0;
uint8_t code;
/* If the exit code is not given on the command line,
* don't reset it to zero: just keep it as it might