Lines Matching refs:cs
34 service(register Coshell_t* co, Coservice_t* cs, Cojob_t* cj, int flags, Sfio_t* sp)
47 for (a = cs->argv; *a; a++)
51 errormsg(state.lib, ERROR_LIBRARY|2, "service %s:%s", cs->path, s);
55 errormsg(state.lib, ERROR_LIBRARY|ERROR_SYSTEM|2, "%s: cannot allocate service pipe", cs->name);
65 cs->fd = fds[1];
70 if (!(proc = procopen(cs->path, cs->argv, NiL, ops, PROC_DAEMON|PROC_IGNORE)))
72 errormsg(state.lib, ERROR_LIBRARY|ERROR_SYSTEM|2, "%s: cannot connect to %s service", cs->path, cs->name);
77 fcntl(cs->fd, F_SETFD, FD_CLOEXEC);
78 cs->pid = proc->pid;
84 if (write(cs->fd, s, n) != n || sfpoll(&co->msgfp, 1, 5 * 1000) <= 0)
89 cj->service = cs;
96 errormsg(state.lib, ERROR_LIBRARY|ERROR_SYSTEM|2, "%s: service not responding", cs->name);
99 cs->pid = 0;
100 close(cs->fd);
101 cs->fd = -1;
106 request(register Coshell_t* co, Cojob_t* cj, Coservice_t* cs, const char* action, int flags)
117 if (!cs->fd && !service(co, cs, cj, flags, sp))
119 if (!cs->pid)
122 errormsg(state.lib, ERROR_LIBRARY|2, "job %d commands:\n\n%s %s\n", cj->id, cs->name, action);
124 sfprintf(sfstderr, "+ %s %s\n", cs->name, action);
128 while ((i = write(cs->fd, action, n)) > 0 && (n -= i) > 0)
137 cj->service = cs;
153 register Coservice_t* cs;
198 for (cs = co->service; cs; cs = cs->next)
200 for (s = cs->name, t = (char*)action; *s && *s == *t; s++, t++);
202 return request(co, cj, cs, t + 1, flags);