diff --git a/src/bin/Jamfile b/src/bin/Jamfile index 81b31f33cf..9579e39826 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -50,7 +50,6 @@ StdBinCommands unchop.c uptime.cpp vmstat.cpp - waitfor.c # whoami.c : : $(haiku-utils_rsrc) ; @@ -102,6 +101,7 @@ StdBinCommands setversion.cpp trash.cpp version.cpp + waitfor.cpp WindowShade.cpp # yes.cpp : be : $(haiku-utils_rsrc) ; diff --git a/src/bin/waitfor.c b/src/bin/waitfor.c deleted file mode 100644 index 29d7f84169..0000000000 --- a/src/bin/waitfor.c +++ /dev/null @@ -1,42 +0,0 @@ -/* waitfor.c - waits for a given threadname - * (c) 2002, François Revol (mmu_man) for OpenBeOS - * released under the MIT licence. - * - * ChangeLog: - * 04-26-2002 v1.0 - * Initial. - * - * waitfor threadname - * thesnooze() time is the same as the original, found using bdb waitfor foobar, - * and stepping until the snooze() call returns, the value is at the push - * instruction just before the call. - */ - -#include -#include - -#define SNOOZE_TIME 100000 - -int main(int argc, char **argv) -{ - status_t ret; - - 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; - } - - return 0; -} - diff --git a/src/bin/waitfor.cpp b/src/bin/waitfor.cpp new file mode 100644 index 0000000000..2809788725 --- /dev/null +++ b/src/bin/waitfor.cpp @@ -0,0 +1,60 @@ +/* waitfor.c - waits for a given threadname + * (c) 2002, François Revol (mmu_man) for OpenBeOS + * released under the MIT licence. + * + * ChangeLog: + * 04-26-2002 v1.0 + * Initial. + * + * waitfor threadname + * thesnooze() time is the same as the original, found using bdb waitfor foobar, + * and stepping until the snooze() call returns, the value is at the push + * instruction just before the call. + */ + +#include +#include + +#include + + +#define SNOOZE_TIME 100000 + + +int +main(int argc, char** argv) +{ + if (argc == 2) { + while (find_thread(argv[1]) < 0) { + if (snooze(SNOOZE_TIME) != B_OK) + return 1; + } + } else if (argc == 3 && strcmp(argv[1], "-e") == 0) { + while (find_thread(argv[2]) >= 0) { + if (snooze(SNOOZE_TIME) != B_OK) + return 1; + } + } else if (argc == 3 && strcmp(argv[1], "-m") == 0) { + while (true) { + BMessenger messenger(argv[2]); + if (messenger.IsValid()) + break; + if (snooze(SNOOZE_TIME) != B_OK) + return 1; + } + } else { + fprintf(stderr, + "Usage:\n" + " %s \n" + " wait until a thread with 'thread_name' has been started.\n\n" + " %s -e \n" + " wait until all threads with thread_name have ended.\n\n" + " %s -m \n" + " wait until the application specified by 'app_signature' is " + "is ready to receive messages.\n", argv[0], argv[0], argv[0]); + return 1; + } + + return 0; +} +