diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-09 19:04:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-09 19:04:19 +0000 |
commit | 8f9464256fc06a884bf589b4004262a0549d11b3 (patch) | |
tree | a088b8acbebdefe2acf0b41cfed4418830275b78 /src/arm/arm_api.c | |
parent | 817ee37a75fb8eb5887023d1a5152cb528ee2d5a (diff) | |
download | gnunet-8f9464256fc06a884bf589b4004262a0549d11b3.tar.gz gnunet-8f9464256fc06a884bf589b4004262a0549d11b3.zip |
-LRN: Another take on std descriptor inheritance
Now descriptors are not inherited by default, you have to pass
a set of flags to make it so. When pipes are given, flags have
no effect.
gnunet-arm now has two options to block stdout and stderr from being
passed to gnunet-service-arm
Diffstat (limited to 'src/arm/arm_api.c')
-rw-r--r-- | src/arm/arm_api.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 1b78d3393..a598a5fea 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -295,6 +295,11 @@ struct RequestContext | |||
295 | */ | 295 | */ |
296 | uint16_t type; | 296 | uint16_t type; |
297 | 297 | ||
298 | /** | ||
299 | * Flags for passing std descriptors to ARM (when starting ARM). | ||
300 | */ | ||
301 | enum GNUNET_OS_InheritStdioFlags std_inheritance; | ||
302 | |||
298 | }; | 303 | }; |
299 | 304 | ||
300 | #include "do_start_process.c" | 305 | #include "do_start_process.c" |
@@ -381,14 +386,14 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
381 | { | 386 | { |
382 | /* Means we are ONLY running locally */ | 387 | /* Means we are ONLY running locally */ |
383 | /* we're clearly running a test, don't daemonize */ | 388 | /* we're clearly running a test, don't daemonize */ |
384 | proc = do_start_process (GNUNET_NO, | 389 | proc = do_start_process (GNUNET_NO, pos->std_inheritance, |
385 | NULL, loprefix, binary, "-c", config, | 390 | NULL, loprefix, binary, "-c", config, |
386 | /* no daemonization! */ | 391 | /* no daemonization! */ |
387 | lopostfix, NULL); | 392 | lopostfix, NULL); |
388 | } | 393 | } |
389 | else | 394 | else |
390 | { | 395 | { |
391 | proc = do_start_process (GNUNET_NO, | 396 | proc = do_start_process (GNUNET_NO, pos->std_inheritance, |
392 | NULL, loprefix, binary, "-c", config, | 397 | NULL, loprefix, binary, "-c", config, |
393 | "-d", lopostfix, NULL); | 398 | "-d", lopostfix, NULL); |
394 | } | 399 | } |
@@ -522,6 +527,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
522 | * | 527 | * |
523 | * @param h handle to ARM | 528 | * @param h handle to ARM |
524 | * @param service_name name of the service | 529 | * @param service_name name of the service |
530 | * @param std_inheritance inheritance of std streams | ||
525 | * @param timeout how long to wait before failing for good | 531 | * @param timeout how long to wait before failing for good |
526 | * @param cb callback to invoke when service is ready | 532 | * @param cb callback to invoke when service is ready |
527 | * @param cb_cls closure for callback | 533 | * @param cb_cls closure for callback |
@@ -529,6 +535,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
529 | void | 535 | void |
530 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | 536 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, |
531 | const char *service_name, | 537 | const char *service_name, |
538 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | ||
532 | struct GNUNET_TIME_Relative timeout, | 539 | struct GNUNET_TIME_Relative timeout, |
533 | GNUNET_ARM_Callback cb, void *cb_cls) | 540 | GNUNET_ARM_Callback cb, void *cb_cls) |
534 | { | 541 | { |
@@ -547,12 +554,13 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
547 | sctx->callback = cb; | 554 | sctx->callback = cb; |
548 | sctx->cls = cb_cls; | 555 | sctx->cls = cb_cls; |
549 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 556 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
557 | sctx->std_inheritance = std_inheritance; | ||
550 | memcpy (&sctx[1], service_name, slen); | 558 | memcpy (&sctx[1], service_name, slen); |
551 | GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, | 559 | GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, |
552 | sctx); | 560 | sctx); |
553 | return; | 561 | return; |
554 | } | 562 | } |
555 | if (h->client == NULL) | 563 | if (NULL == h->client) |
556 | { | 564 | { |
557 | client = GNUNET_CLIENT_connect ("arm", h->cfg); | 565 | client = GNUNET_CLIENT_connect ("arm", h->cfg); |
558 | if (client == NULL) | 566 | if (client == NULL) |