1 /* waitfor.c - waits for a given threadname
2 * (c) 2002, François Revol (mmu_man) for OpenBeOS
3 * released under the MIT licence.
10 * thesnooze() time is the same as the original, found using bdb waitfor foobar,
11 * and stepping until the snooze() call returns, the value is at the push
12 * instruction just before the call.
18 #include <Messenger.h>
21 #define SNOOZE_TIME 100000
25 main(int argc
, char** argv
)
28 while (find_thread(argv
[1]) < 0) {
29 if (snooze(SNOOZE_TIME
) != B_OK
)
32 } else if (argc
== 3 && strcmp(argv
[1], "-e") == 0) {
33 while (find_thread(argv
[2]) >= 0) {
34 if (snooze(SNOOZE_TIME
) != B_OK
)
37 } else if (argc
== 3 && strcmp(argv
[1], "-m") == 0) {
39 BMessenger
messenger(argv
[2]);
40 if (messenger
.IsValid())
42 if (snooze(SNOOZE_TIME
) != B_OK
)
49 " wait until a thread with 'thread_name' has been started.\n\n"
50 " %s -e <thread_name>\n"
51 " wait until all threads with thread_name have ended.\n\n"
52 " %s -m <app_signature>\n"
53 " wait until the application specified by 'app_signature' is "
54 "is ready to receive messages.\n", argv
[0], argv
[0], argv
[0]);