Subversion Repositories MLServ

Rev

Rev 4 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 5
Line 1... Line 1...
1
/* $Id: ipc.c 4 2024-09-24 18:35:15Z nishi $ */
1
/* $Id: ipc.c 5 2024-09-25 00:19:35Z nishi $ */
2
 
2
 
3
#include "cm_ipc.h"
3
#include "cm_ipc.h"
4
 
4
 
5
#include <sys/socket.h>
5
#include <sys/socket.h>
6
#include <sys/un.h>
6
#include <sys/un.h>
7
#include <string.h>
7
#include <string.h>
8
#include <unistd.h>
8
#include <unistd.h>
9
#include <stdio.h>
9
#include <stdio.h>
-
 
10
#include <sys/stat.h>
10
 
11
 
11
int cm_ipc_connect(void) {
12
int cm_ipc_connect(void) {
12
	struct sockaddr_un sun;
13
	struct sockaddr_un sun;
13
	memset(&sun, 0, sizeof(sun));
14
	memset(&sun, 0, sizeof(sun));
14
	int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
15
	int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
Line 41... Line 42...
41
	}
42
	}
42
	if(listen(sock, 128) == -1) {
43
	if(listen(sock, 128) == -1) {
43
		close(sock);
44
		close(sock);
44
		return -1;
45
		return -1;
45
	}
46
	}
-
 
47
	chmod(sun.sun_path, 0660);
46
	return sock;
48
	return sock;
47
}
49
}