[Jack-Devel] jack_wait extensions
Hi!
I recently came across jack_wait and wanted to use this tool for
scripting. Besides parsing the output, there is no way to check if jackd
is now running or not.
I propose to set the exit code. This way, a script can tell if the
server isn't running when it is supposed to be (-c option, exit code 2),
when the operation just timed out (-t, exit code 3), there was something
wrong (exit code 1) or when everything was fine (rc 0).
Given that this is a semantic change, it might break existing
functionality for those who already use it in scripts. What do you
think?
Cheers
PS: Patch is untested, just for discussion...
diff --git a/example-clients/wait.c b/example-clients/wait.c
index 9150bb6..b6f77e5 100644
--- a/example-clients/wait.c
+++ b/example-clients/wait.c
@@ -92,6 +92,7 @@ main (int argc, char *argv[])
start_timestamp = time( NULL );
+ int rc = 0;
while(1) {
client = jack_client_open ("wait", options, &status, server_name);
/* check for some real error and bail out */
@@ -108,6 +109,7 @@ main (int argc, char *argv[])
}
if( just_check ) {
fprintf( stdout, "not running\n" );
+ rc = 2;
break;
}
} else {
@@ -124,6 +126,7 @@ main (int argc, char *argv[])
if( wait_timeout ) {
if( (time( NULL ) - start_timestamp) > wait_timeout ) {
fprintf( stdout, "timeout\n" );
+ rc = 3;
break;
}
}
@@ -132,5 +135,5 @@ main (int argc, char *argv[])
sleep(1);
}
- exit (0);
+ exit (rc);
}
1311905809.26402_0.ltw:2,a <4E3217D5.5080609 at drcomp dot erfurt dot thur dot de>