YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RunServer.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/run/Run.h>
14
17
18#include <yarp/os/Network.h>
19#include <yarp/os/Os.h>
20#include <yarp/os/LogStream.h>
21#include <yarp/os/RpcClient.h>
22#include <yarp/os/RpcServer.h>
23#include <yarp/os/Semaphore.h>
24#include <yarp/os/SystemInfo.h>
26#include <yarp/os/Time.h>
27
31
32#include <cstdio>
33#include <string>
34#include <cstring>
35#include <random>
36
38namespace fs = yarp::conf::filesystem;
41
42//This anonymous namespace make this symbol visible only
43//inside this translation unit.
44namespace
45{
46 void sigint_handler(int sig)
47 {
48 YARP_UNUSED(sig);
49 yarp::run::Run::mStresstest=false;
50
51 if (yarp::run::Run::pServerPort)
52 {
53 yarp::os::RpcServer *pClose=yarp::run::Run::pServerPort;
54 yarp::run::Run::pServerPort = nullptr;
55 pClose->close();
56 }
57 //else
58 //{
59 //}
60 }
61}
62
63static yarp::os::Bottle parsePaths(const std::string& txt)
64{
65 yarp::os::Bottle result;
66 const char *at = txt.c_str();
67 int slash_tweak = 0;
68 int len = 0;
69 for (char ch : txt) {
70 if (ch==sep) {
71 result.addString(std::string(at, len-slash_tweak));
72 at += len+1;
73 len = 0;
74 slash_tweak = 0;
75 continue;
76 }
77 slash_tweak = (ch==slash && len>0)?1:0;
78 len++;
79 }
80 if (len>0) {
81 result.addString(std::string(at, len-slash_tweak));
82 }
83 return result;
84}
85
86static bool fileExists(const char *fname)
87{
88 FILE *fp = nullptr;
89 fp = fopen(fname, "r");
90 if (!fp) {
91 return false;
92 } else {
93 fclose(fp);
94 return true;
95 }
96}
97
99// WINDOWS SERVER
100#if defined(_WIN32)
101int yarp::run::Run::server()
102{
103 //yarp::os::Semaphore serializer(1); ///?????unused
104
106
107 if (!port.open(mPortName.c_str()))
108 {
109 yError() << "Yarprun failed to open port: " << mPortName.c_str();
110 return YARPRUN_ERROR;
111 }
112
113 yarp::os::Bottle cmd, reply;
114 cmd.addString("set");
115 cmd.addString(port.getName());
116 cmd.addString("yarprun");
117 cmd.addString("true");
119
120 yInfo() << "Yarprun successfully started on port: " << mPortName.c_str();
121
122 pServerPort=&port;
123
124 yarp::os::impl::signal(SIGINT, sigint_handler);
125 yarp::os::impl::signal(SIGTERM, sigint_handler);
126
127 // Enabling cpu load collector on windows
128 //yarp::os::impl::SystemInfo::enableCpuLoadCollector();
129
130 while (pServerPort)
131 {
133
134 RUNLOG("<<<port.read(msg, true)")
135 if (!port.read(msg, true)) break;
136 RUNLOG(">>>port.read(msg, true)")
137
138 if (!pServerPort) break;
139
140 //printf("<<< %s >>>\n", msg.toString().c_str());
141 //fflush(stdout);
142
144
145 // command with stdio management
146 if (msg.check("stdio"))
147 {
148 std::string strOnPort=msg.find("on").asString();
149 std::string strStdioPort=msg.find("stdio").asString();
150
151 if (strOnPort==mPortName)
152 {
153 std::string strUUID=mPortName+"/"+int2String(getpid())+"/"+msg.find("as").asString()+"-"+int2String(mProcCNT++);
154 yarp::os::Bottle botUUID;
155 botUUID.addString("stdiouuid");
156 botUUID.addString(strUUID.c_str());
157 msg.addList()=botUUID;
158
159 if (mLogged || msg.check("log"))
160 {
161 std::string strAlias=msg.find("as").asString();
162 std::string portName="/log";
163 portName+=mPortName+"/";
164 std::string command = msg.findGroup("cmd").get(1).asString();
165 command = command.substr(0, command.find(' '));
166 command = command.substr(command.find_last_of("\\/") + 1);
167 portName+=command;
168
169 yarp::os::Bottle botFwd;
170 botFwd.addString("forward");
171 botFwd.addString(portName.c_str());
172 if (msg.check("log"))
173 {
174 yarp::os::Bottle botLogger=msg.findGroup("log");
175
176 if (botLogger.size()>1)
177 {
178 botFwd.addString(botLogger.get(1).asString());
179 }
180 else
181 {
182 botFwd.addString(mLoggerPort);
183 }
184 }
185 else
186 {
187 botFwd.addString(mLoggerPort);
188 }
189 msg.addList()=botFwd;
190 }
191
192 yarp::os::Bottle cmdResult;
193 if (executeCmdAndStdio(msg, cmdResult)>0)
194 {
195 if (strStdioPort==mPortName)
196 {
197 yarp::os::Bottle stdioResult;
198 userStdio(msg, stdioResult);
199 cmdResult.append(stdioResult);
200 }
201 else
202 {
203 cmdResult.append(sendMsg(msg, strStdioPort));
204 }
205 }
206
207 port.reply(cmdResult);
208 }
209 else
210 {
211 yarp::os::Bottle stdioResult;
212 userStdio(msg, stdioResult);
213 port.reply(stdioResult);
214 }
215
216 continue;
217 }
218
219 // without stdio
220 if (msg.check("cmd"))
221 {
222 yarp::os::Bottle cmdResult;
223
224 if (msg.check("log"))
225 {
226 yarp::os::Bottle botLogger=msg.findGroup("log");
227
228 if (botLogger.size()>1)
229 {
230 std::string loggerName=botLogger.get(1).asString();
231 executeCmdStdout(msg, cmdResult, loggerName);
232 }
233 else
234 {
235 executeCmdStdout(msg, cmdResult, mLoggerPort);
236 }
237 }
238 else if (mLogged)
239 {
240 executeCmdStdout(msg, cmdResult, mLoggerPort);
241 }
242 else
243 {
244 executeCmd(msg, cmdResult);
245 }
246 port.reply(cmdResult);
247 continue;
248 }
249
250 if (msg.check("kill"))
251 {
252 std::string alias(msg.findGroup("kill").get(1).asString());
253 int sig=msg.findGroup("kill").get(2).asInt32();
254 yarp::os::Bottle result;
255 result.addString(mProcessVector.Signal(alias, sig)?"kill OK":"kill FAILED");
256 port.reply(result);
257 continue;
258 }
259
260 if (msg.check("sigterm"))
261 {
262 std::string alias(msg.find("sigterm").asString());
263 yarp::os::Bottle result;
264 result.addString(mProcessVector.Signal(alias, SIGTERM)?"sigterm OK":"sigterm FAILED");
265 port.reply(result);
266 continue;
267 }
268
269 if (msg.check("sigtermall"))
270 {
271 mProcessVector.Killall(SIGTERM);
272 yarp::os::Bottle result;
273 result.addString("sigtermall OK");
274 port.reply(result);
275 continue;
276 }
277
278 if (msg.check("ps"))
279 {
280 yarp::os::Bottle result;
281 result.append(mProcessVector.PS());
282 port.reply(result);
283 continue;
284 }
285
286 if (msg.check("isrunning"))
287 {
288 std::string alias(msg.find("isrunning").asString());
289 yarp::os::Bottle result;
290 result.addString(mProcessVector.IsRunning(alias)?"running":"not running");
291 port.reply(result);
292 continue;
293 }
294
295 if (msg.check("killstdio"))
296 {
297 std::string alias(msg.find("killstdio").asString());
298 mStdioVector.Signal(alias, SIGTERM);
299 yarp::os::Bottle result;
300 result.addString("killstdio OK");
301 port.reply(result);
302 continue;
303 }
304
306
307 if (msg.check("sysinfo"))
308 {
310 port.reply(sysinfo);
311 continue;
312 }
313
314 if (msg.check("which"))
315 {
316 std::string fileName=msg.find("which").asString();
317 if (fileName!="")
318 {
320 for (int i=0; i<possiblePaths.size(); ++i)
321 {
322 std::string guessString=possiblePaths.get(i).asString() +
323 std::string{slash} + fileName;
324 const char* guess=guessString.c_str();
325 if (fileExists (guess))
326 {
327 fileName= "\"" + std::string(guess) + "\"";
328 break;
329 }
330 }
331 }
332 yarp::os::Value fileNameWriter(fileName);
333 port.reply(fileNameWriter);
334 continue;
335 }
336
337 if (msg.check("exit"))
338 {
339 yInfo() << "Yarprun server closing...";
340 pServerPort=0;
341 yarp::os::Bottle result;
342 result.addString("exit OK");
343 port.reply(result);
344 port.close();
345 }
346 }
347
348
349 Run::mStdioVector.Killall(SIGTERM);
350
351 Run::mProcessVector.Killall(SIGTERM);
352
353 yInfo() << "Yarprun server closed";
354 return 0;
355}
356
358#else // LINUX SERVER
360
361void yarp::run::Run::cleanBeforeExec()
362{
363 // zombie hunter stop
364
365 //yarp::os::impl::signal(SIGPIPE, SIG_IGN);
366 //yarp::os::impl::signal(SIGCHLD, SIG_DFL);
367 //yarp::os::impl::signal(SIGINT, SIG_DFL);
368 //yarp::os::impl::signal(SIGTERM, SIG_DFL);
369
370 if (mProcessVector)
371 {
372 YarpRunInfoVector *p=mProcessVector;
373 mProcessVector = nullptr;
374 delete p;
375 }
376 if (mStdioVector)
377 {
378 YarpRunInfoVector *p=mStdioVector;
379 mStdioVector = nullptr;
380 delete p;
381 }
382 if (mBraveZombieHunter)
383 {
384 ZombieHunterThread *p=mBraveZombieHunter;
385 mBraveZombieHunter = nullptr;
386 p->stop();
387 delete p;
388 }
389
390 //yarp::os::Network::fini();
391}
392
393void yarp::run::Run::writeToPipe(int fd, std::string str)
394{
395 int len = str.length() + 1;
396 int ret;
397 ret = write(fd, &len, sizeof(len));
398 if (ret != sizeof(len)) {
399 fprintf(stderr, "Warning: could not write string length to pipe.\n");
400 }
401 ret = write(fd, str.c_str(), len);
402 if (ret != len) {
403 fprintf(stderr, "Warning: could not write string to pipe.\n");
404 }
405}
406
407int yarp::run::Run::readFromPipe(int fd, char* &data, int& buffsize)
408{
409 int len=0;
410 char* buff=(char*)&len;
411
412 for (int c=4, r=0; c>0; c-=r)
413 {
414 r=read(fd, buff, c);
415
416 if (r < 1) {
417 return -1;
418 }
419
420 buff+=r;
421 }
422
423 if (len <= 0) {
424 return 0;
425 }
426
427 if (len>buffsize)
428 {
429 delete [] data;
430 data=new char[buffsize=1024+(len/1024)*1024];
431 }
432
433 buff=data;
434
435 for (int c=len, r=0; c>0; c-=r)
436 {
437 r=read(fd, buff, c);
438
439 if (r < 1) {
440 return -1;
441 }
442
443 buff+=r;
444 }
445
446 return len;
447}
448
449static void sigchld_handler(int sig)
450{
451 YARP_UNUSED(sig);
452 if (yarp::run::Run::mBraveZombieHunter)
453 {
454 yarp::run::Run::mBraveZombieHunter->sigchldHandler();
455 }
456}
457
458int yarp::run::Run::server()
459{
460 int pipe_server2manager[2];
461 int pipe_manager2server[2];
462
463 if (yarp::run::impl::pipe(pipe_server2manager))
464 {
465 fprintf(stderr, "Can't open pipe because %s\n", strerror(errno));
466 fflush(stderr);
467
468 return YARPRUN_ERROR;
469 }
470
471 if (yarp::run::impl::pipe(pipe_manager2server))
472 {
473 fprintf(stderr, "Can't open pipe because %s\n", strerror(errno));
474 fflush(stderr);
475
476 return YARPRUN_ERROR;
477 }
478
479 int pid_process_manager=yarp::run::impl::fork();
480
481 if (IS_INVALID(pid_process_manager))
482 {
483 int error=errno;
484
485 CLOSE(pipe_server2manager[WRITE_TO_PIPE]);
486 CLOSE(pipe_server2manager[READ_FROM_PIPE]);
487 CLOSE(pipe_manager2server[WRITE_TO_PIPE]);
488 CLOSE(pipe_manager2server[READ_FROM_PIPE]);
489
490 fprintf(stderr, "Can't fork process manager because %s\n", strerror(error));
491 fflush(stderr);
492
493 return YARPRUN_ERROR;
494 }
495
496 if (IS_PARENT_OF(pid_process_manager))
497 {
498 yarp::os::impl::signal(SIGPIPE, SIG_IGN);
499
500 CLOSE(pipe_server2manager[READ_FROM_PIPE]);
501 CLOSE(pipe_manager2server[WRITE_TO_PIPE]);
502
504
505 if (!port.open(mPortName))
506 {
507 yError() << "Yarprun failed to open port: " << mPortName.c_str();
508
509 if (mPortName[0] != '/') {
510 yError("Invalid port name '%s', it should start with '/'\n", mPortName.c_str());
511 }
512 return YARPRUN_ERROR;
513 }
514 yarp::os::Bottle cmd, reply;
515 cmd.addString("set");
516 cmd.addString(port.getName());
517 cmd.addString("yarprun");
518 cmd.addString("true");
519
521
522 yInfo() << "Yarprun successfully started on port: " << mPortName.c_str();
523
524 pServerPort=&port;
525
526 yarp::os::impl::signal(SIGINT, sigint_handler);
527 yarp::os::impl::signal(SIGTERM, sigint_handler);
528
529 int rsp_size=1024;
530 char *rsp_str=new char[rsp_size];
531
532 yarp::os::Bottle msg, response;
533
534 while (pServerPort)
535 {
536 RUNLOG("<<<port.read(msg, true)")
537 if (!port.read(msg, true)) {
538 break;
539 }
540 RUNLOG(">>>port.read(msg, true)")
541
542 if (!pServerPort) {
543 break;
544 }
545
546 if (msg.check("sysinfo"))
547 {
549 port.reply(sysinfo);
550 continue;
551 }
552
553 if (msg.check("which"))
554 {
555 std::string fileName=msg.find("which").asString();
556 if (fileName!="")
557 {
559 for (size_t i=0; i<possiblePaths.size(); ++i)
560 {
561 std::string guessString=possiblePaths.get(i).asString() + slash + fileName;
562 const char* guess=guessString.c_str();
563 if (fileExists (guess))
564 {
565 fileName = guess;
566 break;
567 }
568 }
569 }
570 yarp::os::Value fileNameWriter(fileName);
571 port.reply(fileNameWriter);
572 continue;
573 }
574
575 if (msg.check("exit"))
576 {
577 pServerPort = nullptr;
578 yarp::os::Bottle result;
579 result.addString("exit OK");
580 port.reply(result);
581 port.close();
582 break;
583 }
584
585 RUNLOG("<<<writeToPipe")
586 writeToPipe(pipe_server2manager[WRITE_TO_PIPE], msg.toString());
587 RUNLOG(">>>writeToPipe")
588
589 RUNLOG("<<<readFromPipe")
590 int nread=readFromPipe(pipe_manager2server[READ_FROM_PIPE], rsp_str, rsp_size);
591 RUNLOG(">>>readFromPipe")
592
593 if (nread<0)
594 {
595 fprintf(stderr, "ERROR: broken pipe between server and manager\n");
596 fflush(stderr);
597 break;
598 }
599
600 if (nread)
601 {
602 response.fromString(rsp_str);
603 port.reply(response);
604 }
605 }
606
607 //yarp::os::Network::fini();
608
609 CLOSE(pipe_server2manager[WRITE_TO_PIPE]);
610 CLOSE(pipe_manager2server[READ_FROM_PIPE]);
611
612 delete [] rsp_str;
613
614 return 0;
615 }
616
617 if (IS_NEW_PROCESS(pid_process_manager))
618 {
619 yarp::os::impl::signal(SIGPIPE, SIG_IGN);
620
621 CLOSE(pipe_server2manager[WRITE_TO_PIPE]);
622 CLOSE(pipe_manager2server[READ_FROM_PIPE]);
623
624 //yarp::os::Network::init();
625
626 mProcessVector=new YarpRunInfoVector;
627 mStdioVector=new YarpRunInfoVector;
628
629 mBraveZombieHunter=new ZombieHunterThread;
630 mBraveZombieHunter->start();
631
632 yarp::os::impl::signal(SIGCHLD, sigchld_handler);
633 //yarp::os::impl::signal(SIGINT, SIG_IGN);
634 //yarp::os::impl::signal(SIGTERM, SIG_IGN);
635
636 int msg_size=1024;
637 char *msg_str=new char[msg_size];
638
640
641 //while(readFromPipe(pipe_server2manager[READ_FROM_PIPE], msg_str, msg_size)>0)
642 while (true)
643 {
644 RUNLOG("<<<readFromPipe")
645 if (readFromPipe(pipe_server2manager[READ_FROM_PIPE], msg_str, msg_size) <= 0) {
646 break;
647 }
648 RUNLOG(">>>readFromPipe")
649
650 //printf("<<< %s >>>\n", msg_str);
651 //fflush(stdout);
652
653 msg.fromString(msg_str);
654
655 // command with stdio management
656 if (msg.check("stdio"))
657 {
658 std::string strOnPort=msg.find("on").asString();
659 std::string strStdioPort=msg.find("stdio").asString();
660
661 if (strOnPort==mPortName)
662 {
663 std::string strUUID=mPortName+"/"+int2String(getpid())+"/"+msg.find("as").asString()+"-"+int2String(mProcCNT++);
664 yarp::os::Bottle botUUID;
665 botUUID.addString("stdiouuid");
666 botUUID.addString(strUUID.c_str());
667 msg.addList()=botUUID;
668
669 if (mLogged || msg.check("log"))
670 {
671 std::string strAlias=msg.find("as").asString();
672 std::string portName="/log";
673 portName+=mPortName+"/";
674 std::string command = msg.findGroup("cmd").get(1).asString();
675 command = command.substr(0, command.find(' '));
676 command = command.substr(command.find_last_of("\\/") + 1);
677 portName+=command;
678
679 yarp::os::Bottle botFwd;
680 botFwd.addString("forward");
681 botFwd.addString(portName.c_str());
682 if (msg.check("log"))
683 {
684 yarp::os::Bottle botLogger=msg.findGroup("log");
685
686 if (botLogger.size()>1)
687 {
688 botFwd.addString(botLogger.get(1).asString());
689 }
690 else
691 {
692 botFwd.addString(mLoggerPort);
693 }
694 }
695 else
696 {
697 botFwd.addString(mLoggerPort);
698 }
699 msg.addList()=botFwd;
700
702 style.persistent=true;
703 yarp::os::Network::connect(portName, mLoggerPort, style);
704 }
705
706 yarp::os::Bottle cmdResult;
707 if (executeCmdAndStdio(msg, cmdResult)>0)
708 {
709 if (strStdioPort==mPortName)
710 {
711 yarp::os::Bottle stdioResult;
712 userStdio(msg, stdioResult);
713 cmdResult.append(stdioResult);
714 }
715 else
716 {
717 cmdResult.append(sendMsg(msg, strStdioPort));
718 }
719 }
720
721 RUNLOG("<<<writeToPipe")
722 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], cmdResult.toString());
723 RUNLOG(">>>writeToPipe")
724 }
725 else
726 {
727 yarp::os::Bottle stdioResult;
728 userStdio(msg, stdioResult);
729 RUNLOG("<<<writeToPipe")
730 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], stdioResult.toString());
731 RUNLOG(">>>writeToPipe")
732 }
733
734 continue;
735 }
736
737 // without stdio
738 if (msg.check("cmd"))
739 {
740 yarp::os::Bottle cmdResult;
741
742 if (msg.check("log"))
743 {
744 yarp::os::Bottle botLogger=msg.findGroup("log");
745
746 if (botLogger.size()>1)
747 {
748 std::string loggerName=botLogger.get(1).asString();
749 executeCmdStdout(msg, cmdResult, loggerName);
750 }
751 else
752 {
753 executeCmdStdout(msg, cmdResult, mLoggerPort);
754 }
755 }
756 else if (mLogged)
757 {
758 executeCmdStdout(msg, cmdResult, mLoggerPort);
759 }
760 else
761 {
762 executeCmd(msg, cmdResult);
763 }
764
765 RUNLOG("<<<writeToPipe")
766 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], cmdResult.toString());
767 RUNLOG(">>>writeToPipe")
768 continue;
769 }
770
771 if (msg.check("kill"))
772 {
773 std::string alias(msg.findGroup("kill").get(1).asString());
774 int sig=msg.findGroup("kill").get(2).asInt32();
775 yarp::os::Bottle result;
776 result.addString(mProcessVector->Signal(alias, sig)?"kill OK":"kill FAILED");
777 RUNLOG("<<<writeToPipe")
778 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
779 RUNLOG(">>>writeToPipe")
780 continue;
781 }
782
783 if (msg.check("sigterm"))
784 {
785 std::string alias(msg.find("sigterm").asString());
786 yarp::os::Bottle result;
787 result.addString(mProcessVector->Signal(alias, SIGTERM)?"sigterm OK":"sigterm FAILED");
788 RUNLOG("<<<writeToPipe")
789 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
790 RUNLOG(">>>writeToPipe")
791 continue;
792 }
793
794 if (msg.check("sigtermall"))
795 {
796 mProcessVector->Killall(SIGTERM);
797 yarp::os::Bottle result;
798 result.addString("sigtermall OK");
799
800 RUNLOG("<<<writeToPipe")
801 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
802 RUNLOG(">>>writeToPipe")
803 continue;
804 }
805
806 if (msg.check("ps"))
807 {
808 yarp::os::Bottle result;
809 result.append(mProcessVector->PS());
810 RUNLOG("<<<writeToPipe")
811 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
812 RUNLOG(">>>writeToPipe")
813 continue;
814 }
815
816 if (msg.check("isrunning"))
817 {
818 std::string alias(msg.find("isrunning").asString());
819 yarp::os::Bottle result;
820 result.addString(mProcessVector->IsRunning(alias)?"running":"not running");
821 RUNLOG("<<<writeToPipe")
822 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
823 RUNLOG(">>>writeToPipe")
824 continue;
825 }
826
827 if (msg.check("killstdio"))
828 {
829 std::string alias(msg.find("killstdio").asString());
830 mStdioVector->Signal(alias, SIGTERM);
831 yarp::os::Bottle result;
832 result.addString("killstdio OK");
833 RUNLOG("<<<writeToPipe")
834 writeToPipe(pipe_manager2server[WRITE_TO_PIPE], result.toString());
835 RUNLOG(">>>writeToPipe")
836 continue;
837 }
838 }
839
840 mStdioVector->Killall(SIGTERM);
841
842 mProcessVector->Killall(SIGTERM);
843
844 if (mBraveZombieHunter)
845 {
846 mBraveZombieHunter->stop();
847 delete mBraveZombieHunter;
848 mBraveZombieHunter = nullptr;
849 }
850
851 delete mProcessVector;
852
853 delete mStdioVector;
854
855 //yarp::os::Network::fini();
856
857 CLOSE(pipe_server2manager[READ_FROM_PIPE]);
858 CLOSE(pipe_manager2server[WRITE_TO_PIPE]);
859
860 delete [] msg_str;
861 }
862
863 return 0;
864} // LINUX SERVER
865#endif
std::string toString(const T &value)
convert an arbitrary type to string.
#define yInfo(...)
Definition Log.h:319
#define yError(...)
Definition Log.h:361
#define RUNLOG(msg)
int CLOSE(int h)
#define YARPRUN_ERROR
std::string int2String(int x)
static yarp::os::Bottle parsePaths(const std::string &txt)
Definition RunServer.cpp:63
constexpr fs::value_type slash
Definition RunServer.cpp:40
constexpr auto sep
Definition RunServer.cpp:39
static bool fileExists(const char *fname)
Definition RunServer.cpp:86
void sigchld_handler(int)
An error handler that reaps the zombies.
bool reply(PortWriter &writer) override
Send an object as a reply to an object read from the port.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
void fromString(const std::string &text)
Initializes bottle from a string.
Definition Bottle.cpp:210
void append(const Bottle &alt)
Append the content of the given bottle to the current list.
Definition Bottle.cpp:359
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition Bottle.cpp:188
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:257
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:252
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition Bottle.cpp:299
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:283
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition Bottle.cpp:176
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Bottle.cpp:293
A mini-server for performing network communication in the background.
Preferences for how to communicate with a contact.
bool persistent
Specify whether a requested connection should be persistent.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition Network.cpp:751
A port that is specialized as an RPC server.
Definition RpcServer.h:23
A helper class to pass the SystemInfo object around the YARP network.
bool stop()
Stop the thread.
Definition Thread.cpp:81
bool start()
Start the new thread running.
Definition Thread.cpp:93
A single value (typically within a Bottle).
Definition Value.h:44
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:210
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
static NameClient & getNameClient()
Get an instance of the name client.
static bool sysinfo(const std::string &node, yarp::os::SystemInfoSerializer &info)
Get a report of system information of a yarprun server.
#define WRITE_TO_PIPE
#define READ_FROM_PIPE
static constexpr char path_separator
Definition environment.h:27
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
Definition environment.h:65
static constexpr value_type preferred_separator
Definition filesystem.h:21
int getpid()
Portable wrapper for the getppid() function.
Definition Os.cpp:84
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
#define YARP_UNUSED(var)
Definition api.h:162