aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-22 18:38:30 +0200
committerMattias Andrée <maandree@kth.se>2016-07-22 18:38:30 +0200
commit9b2a56aab8f4a92843608cbc998af0a10735eed3 (patch)
tree87040d53ae19a7ff8c1860f573658b5a6b6df739
parentBug fixes (diff)
downloadcoopgammad-9b2a56aab8f4a92843608cbc998af0a10735eed3.tar.gz
coopgammad-9b2a56aab8f4a92843608cbc998af0a10735eed3.tar.bz2
coopgammad-9b2a56aab8f4a92843608cbc998af0a10735eed3.tar.xz
bug fixes
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--src/servers/kernel.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/servers/kernel.c b/src/servers/kernel.c
index c168467..85f9eab 100644
--- a/src/servers/kernel.c
+++ b/src/servers/kernel.c
@@ -148,7 +148,7 @@ static int is_pidfile_reusable(const char* restrict pidpath, const char* restric
{
/* PORTERS: /proc/$PID/environ is Linux specific */
- char temp[sizeof("/proc//environ") + 3 * sizeof(pid_t)];
+ char temp[sizeof("/proc//environ") + 3 * sizeof(long long int)];
int fd = -1, saved_errno, tries = 0;
char* content = NULL;
char* p;
@@ -191,9 +191,9 @@ static int is_pidfile_reusable(const char* restrict pidpath, const char* restric
goto bad;
if (*p)
goto bad;
- if ((size_t)(content - p) != n)
+ if ((size_t)(p - content) != n)
goto bad;
- sprintf(temp, "%llu", (unsigned long long)pid);
+ sprintf(temp, "%llu\n", (unsigned long long)pid);
if (strcmp(content, temp))
goto bad;
@@ -218,7 +218,7 @@ static int is_pidfile_reusable(const char* restrict pidpath, const char* restric
return 1;
bad:
- fprintf(stderr, "%s: pid file contain invalid content: %s\n", argv0, pidpath);
+ fprintf(stderr, "%s: pid file contains invalid content: %s\n", argv0, pidpath);
errno = 0;
return -1;
fail:
@@ -265,7 +265,7 @@ int create_pidfile(char* pidpath)
/* Create PID file. */
retry:
- fd = open(pidpath, O_CREAT | O_EXCL, 0644);
+ fd = open(pidpath, O_CREAT | O_EXCL | O_WRONLY, 0644);
if (fd < 0)
{
if (errno == EINTR)