24 Value backlogv = pop_value(vm);
29 fprintf(stderr,
"Runtime type error: unix_listen expects (string path, int backlog)\n");
36 int backlog = (int)backlogv.
i;
38 int s = socket(AF_UNIX, SOCK_STREAM, 0);
40 struct sockaddr_un addr;
41 memset(&addr, 0,
sizeof(addr));
42 addr.sun_family = AF_UNIX;
43 size_t maxlen =
sizeof(addr.sun_path) - 1;
44 strncpy(addr.sun_path,
path, maxlen);
45 addr.sun_path[maxlen] =
'\0';
46 unlink(addr.sun_path);
47 if (bind(
s, (
struct sockaddr *)&addr,
sizeof(addr)) == 0) {
48 if (listen(
s, backlog > 0 ? backlog : 1) == 0) {
push_value(vm, make_int(fd > 0 ? fd :0))
Tagged union representing a Fun value.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.