diff --git a/sta.c b/sta.c
index fd6f8a4..d6e010d 100644
--- a/sta.c
+++ b/sta.c
@@ -117,24 +117,26 @@ void *worker(void *arg)
void run_server(struct sockaddr_un *addr, int sock, Pros *list)
{
int cmds = sizeof(commands) / sizeof(commands[0]);
+
+ if (bind(sock, (struct sockaddr *)addr, sizeof(*addr)) < 0)
+ warn("Bind: failed: %s", strerror(errno));
+
+ if (listen(sock, 5) < 0)
+ warn("Listen failed: %s", strerror(errno));
+
pthread_t tids[cmds];
for (int i = 0; i < cmds; ++i) {
if (commands[i].delay) {
Potato *info = malloc(sizeof(Potato));
info->list = list;
info->id2 = i;
- pthread_create(&tids[i], NULL, worker, info);
+ if (pthread_create(&tids[i], NULL, worker, info))
+ warn("Thread: can't create thread for id: %d", info->id2);
} else {
append(&commands[i], list);
}
}
- if (bind(sock, (struct sockaddr *)addr, sizeof(*addr)) < 0)
- warn("Bind: failed: %s", strerror(errno));
-
- if (listen(sock, 5) < 0)
- warn("Listen failed: %s", strerror(errno));
-
while (1) {
int client = accept(sock, NULL, NULL);
if (client < 0) continue;