> Should we instead just wait indefinitely before returning here?

Would something like the attached patch work for you?

Regards
Martin
>From c47d8a4cb865733c1adb806b1ff2b886783cdc6c Mon Sep 17 00:00:00 2001
From: Martin Willi <[email protected]>
Date: Fri, 8 Aug 2014 10:28:58 +0200
Subject: [PATCH] starter: Wait indefinitely for charon when using --attach-gdb

This makes sure the user has time to set break points etc. before it runs
charon under gdb.
---
 src/starter/invokecharon.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/starter/invokecharon.c b/src/starter/invokecharon.c
index d40ab8c..f94f3ee 100644
--- a/src/starter/invokecharon.c
+++ b/src/starter/invokecharon.c
@@ -201,10 +201,14 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
 		default:
 			/* father */
 			_charon_pid = pid;
-			if (attach_gdb)
+			while (attach_gdb)
 			{
-				/* don't monitor pid file if gdb is attached */
-				return 0;
+				/* wait indefinitely if gdb is attached */
+				usleep(1000);
+				if (stat(pid_file, &stb) == 0)
+				{
+					return 0;
+				}
 			}
 			for (i = 0; i < 500 && _charon_pid; i++)
 			{
-- 
1.9.1

_______________________________________________
Dev mailing list
[email protected]
https://lists.strongswan.org/mailman/listinfo/dev

Reply via email to