X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=src%2Flib%2Fcommon%2Fmailbox.c;h=15418ca41d44838fbefba4feca55e97c6c63a8f1;hp=c749eddd7bda635af6f3355483a05999e800023e;hb=cda63a40d811744c617b18565f091cf5d3a872bd;hpb=c4337f7aecf5d5926f7eb8275985681372e05eca diff --git a/src/lib/common/mailbox.c b/src/lib/common/mailbox.c index c749eddd7..15418ca41 100644 --- a/src/lib/common/mailbox.c +++ b/src/lib/common/mailbox.c @@ -27,12 +27,13 @@ * mailbox.c: Mailbox file access * * Known contributors to this file: - * Markus Armbruster, 2009 + * Markus Armbruster, 2009-2011 */ #include #include +#include #include #include #include @@ -49,11 +50,18 @@ mailbox(char *buf, natid cn) /* * Create an empty telegram file named MBOX. + * Return 0 on success, -1 on failure. */ int mailbox_create(char *mbox) { - close(creat(mbox, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)); + int fd; + + fd = creat(mbox, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + if (fd < 0 || close(fd) < 0) { + logerror("Can't create mailbox %s (%s)", mbox, strerror(errno)); + return -1; + } return 0; }