Lines Matching refs:service

33 	struct service* owner;
50 struct service {
60 ~service();
61 bool operator!=(const struct service& other) const;
62 bool operator==(const struct service& other) const;
79 service::~service()
92 service::operator!=(const struct service& other) const
99 service::operator==(const struct service& other) const
238 Services::_StartService(struct service& service)
240 if (service.stand_alone && service.process == -1) {
241 status_t status = _LaunchService(service, -1);
243 // add service
244 fNameMap[service.name] = &service;
245 service.update = fUpdate;
253 ConnectionList::iterator iterator = service.connections.begin();
254 for (; iterator != service.connections.end(); iterator++) {
275 // open sockets will be closed when the service is deleted
279 // add service to maps and activate it
281 fNameMap[service.name] = &service;
282 service.update = fUpdate;
284 iterator = service.connections.begin();
285 for (; iterator != service.connections.end(); iterator++) {
294 printf("Starting service '%s'\n", service.name.c_str());
300 Services::_StopService(struct service* service)
302 printf("Stop service '%s'\n", service->name.c_str());
304 // remove service from maps
306 ServiceNameMap::iterator iterator = fNameMap.find(service->name);
311 if (!service->stand_alone) {
312 ConnectionList::const_iterator iterator = service->connections.begin();
313 for (; iterator != service->connections.end(); iterator++) {
327 if (service->process != -1) {
328 printf(" Sending SIGTERM to process %" B_PRId32 "\n", service->process);
329 kill(-service->process, SIGTERM);
332 delete service;
338 Services::_ToService(const BMessage& message, struct service*& service)
347 service = new (std::nothrow) ::service;
348 if (service == NULL)
351 service->name = settings.Name();
352 service->stand_alone = settings.IsStandAlone();
353 service->process = -1;
357 service->arguments.push_back(settings.ArgumentAt(i));
363 connection.owner = service;
367 service->connections.push_back(connection);
381 for (int32 index = 0; services.FindMessage("service", index,
383 struct service* service;
384 if (_ToService(message, service) != B_OK)
387 ServiceNameMap::iterator iterator = fNameMap.find(service->name);
389 // this service does not exist yet, start it
390 printf("New service %s\n", service->name.c_str());
391 _StartService(*service);
393 // this service does already exist - check for any changes
395 if (*service != *iterator->second) {
396 printf("Restart service %s\n", service->name.c_str());
398 _StartService(*service);
408 struct service* service = iterator->second;
411 if (service->update != fUpdate) {
412 // this service has to be removed
413 _StopService(service);
420 Services::_LaunchService(struct service& service, int socket)
422 printf("Launch service: %s\n", service.arguments[0].c_str());
446 (service.arguments.size() + 1) * sizeof(char*));
450 for (size_t i = 0; i < service.arguments.size(); i++) {
451 args[i] = service.arguments[i].c_str();
453 args[service.arguments.size()] = NULL;
455 if (execv(service.arguments[0].c_str(), (char* const*)args) < 0) {
467 fprintf(stderr, "Could not start service %s\n",
468 service.name.c_str());
469 } else if (service.stand_alone)
470 service.process = child;
528 // launch this service's handler