buffer[rec-1] = '\0';
break;
}
- ELOG("read() failed!\n");
+ ELOG("read() failed!: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
if (n == 0) {
child_pid = fork();
switch (child_pid) {
case -1:
- ELOG("Couldn't fork()\n");
+ ELOG("Couldn't fork(): %s\n", strerror(errno));
exit(EXIT_FAILURE);
case 0:
/* Child-process. Reroute stdout and start shell */
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
+#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <i3/ipc.h>
uint32_t header_len = strlen(I3_IPC_MAGIC) + sizeof(uint32_t)*2;
char *header = malloc(header_len);
if (header == NULL) {
- ELOG("Could not allocate memory!\n");
+ ELOG("Could not allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
while (rec < header_len) {
int n = read(fd, header + rec, header_len - rec);
if (n == -1) {
- ELOG("read() failed!\n");
+ ELOG("read() failed: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
if (n == 0) {
while (rec < size) {
int n = read(fd, buffer + rec, size - rec);
if (n == -1) {
- ELOG("read() failed!\n");
+ ELOG("read() failed: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
if (n == 0) {
* but we leave it for now */
char *buffer = malloc(to_write);
if (buffer == NULL) {
- ELOG("Could not allocate memory\n");
+ ELOG("Could not allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
while (to_write > 0) {
int n = write(i3_connection.fd, buffer + written, to_write);
if (n == -1) {
- ELOG("write() failed!\n");
+ ELOG("write() failed: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
sock_path = socket_path;
int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (sockfd == -1) {
- ELOG("Could not create Socket!\n");
+ ELOG("Could not create Socket: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
addr.sun_family = AF_LOCAL;
strcpy(addr.sun_path, sock_path);
if (connect(sockfd, (const struct sockaddr*) &addr, sizeof(struct sockaddr_un)) < 0) {
- ELOG("Could not connect to i3!\n");
+ ELOG("Could not connect to i3: %s\n", strerror(errno));
reconnect();
return 0;
}
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include <yajl/yajl_parse.h>
#include "common.h"
params->cur_key = malloc(sizeof(unsigned char) * (keyLen + 1));
if (params->cur_key == NULL) {
- ELOG("Could not allocate memory!\n");
+ ELOG("Could not allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
strncpy(params->cur_key, (const char*) keyVal, keyLen);