From 0ed66b23144b9ab070340ab6443b2c9ccab86d00 Mon Sep 17 00:00:00 2001 From: Alexandre Deckner Date: Tue, 28 Jul 2009 16:16:37 +0000 Subject: [PATCH] * added the inverse [-e] option that waits until all such named threads ended. I use this to cleanly switch between my dev Tracker and the trunk one. I need to wait until it has really quit before overwriting and running another version. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31852 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/waitfor.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/bin/waitfor.c b/src/bin/waitfor.c index 7cdee52926..29d7f84169 100644 --- a/src/bin/waitfor.c +++ b/src/bin/waitfor.c @@ -20,14 +20,23 @@ int main(int argc, char **argv) { status_t ret; - - if (argc != 2) { - fprintf(stderr, "Usage: %s thread_name\n", argv[0]); + + if (argc == 2) { + while (find_thread(argv[1]) < 0) { + if ((ret = snooze(SNOOZE_TIME)) < B_OK) + return 1; + } + } else if (argc == 3 && strcmp(argv[1], "-e") == 0) { + while (find_thread(argv[2]) >= 0) { + if ((ret = snooze(SNOOZE_TIME)) < B_OK) + return 1; + } + } else { + fprintf(stderr, "Usage: %s [-e] thread_name\n" + "-e : wait until all threads with that name ended\n", argv[0]); return 1; } - while (find_thread(argv[1]) < 0) - if ((ret = snooze(SNOOZE_TIME)) < B_OK) - return 1; + return 0; }