Index: uspace/app/tester/proc/task_wait.c
===================================================================
--- uspace/app/tester/proc/task_wait.c	(revision 62273d171a119afa521ee4f4dcb650b5fd54e131)
+++ uspace/app/tester/proc/task_wait.c	(revision d4ec49ec9742a9963af1545a2e50adf65802c994)
@@ -74,7 +74,9 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	TASSERT(texit == TASK_EXIT_UNEXPECTED);
 	TPRINTF("OK\n");
@@ -88,7 +90,9 @@
 
 	TPRINTF("waiting...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
 	rc = task_wait(&wait, &texit, &retval);
 	TPRINTF("done.\n");
 	TASSERT(rc == EINVAL);
+	TASSERT(task_wait_get(&wait) == 0);
 	TPRINTF("OK\n");
 	/* ---- */
@@ -101,7 +105,9 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	TASSERT(texit == TASK_EXIT_UNEXPECTED);
 	/* retval is undefined */
@@ -109,14 +115,17 @@
 	/* ---- */
 
-	TPRINTF("21 ignore retval\n");
+	TPRINTF("21 ignore retval and still wait for exit\n");
 
 	task_wait_set(&wait, TASK_WAIT_EXIT);
-	rc = dummy_task_spawn(&tid, &wait, STR_JOB_OK);
-	TASSERT(rc == EOK);
-
-	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	/* STR_JOB_OK to emulate daemon that eventually terminates */
+	rc = dummy_task_spawn(&tid, &wait, STR_JOB_OK);
+	TASSERT(rc == EOK);
+
+	TPRINTF("waiting...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	TASSERT(texit == TASK_EXIT_NORMAL);
 	/* retval is unknown */
@@ -131,7 +140,9 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	/* exit is not expected */
 	TASSERT(retval == EOK);
@@ -142,5 +153,4 @@
 	TPRINTF("23 partial match (non-exited task)\n");
 
-	// TODO should update wait for synchronized exit waiting
 	task_wait_set(&wait, TASK_WAIT_RETVAL | TASK_WAIT_EXIT);
 	rc = dummy_task_spawn(&tid, &wait, STR_DAEMON);
@@ -148,7 +158,9 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == TASK_WAIT_EXIT);
 	/* exit is not expected */
 	TASSERT(retval == EOK);
@@ -164,7 +176,9 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	TASSERT(texit == TASK_EXIT_NORMAL);
 	/* retval is unknown */
@@ -180,7 +194,10 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	/* Job atomically exited, so there's nothing more to wait for. */
+	TASSERT(task_wait_get(&wait) == 0);
 	/* exit is unknown */
 	TASSERT(retval == EOK);
@@ -198,7 +215,67 @@
 
 	TPRINTF("waiting...");
-	rc = task_wait(&wait, &texit, &retval);
-	TPRINTF("done.\n");
-	TASSERT(rc == EOK);
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
+	TASSERT(texit == TASK_EXIT_NORMAL);
+	TASSERT(retval == EOK);
+	TPRINTF("OK\n");
+	/* ---- */
+
+	TPRINTF("14 partially lost wait\n");
+
+	task_wait_set(&wait, TASK_WAIT_BOTH);
+	rc = dummy_task_spawn(&tid, &wait, STR_FAIL);
+	TASSERT(rc == EOK);
+
+	TPRINTF("waiting...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EINVAL);
+	TASSERT(task_wait_get(&wait) == 0);
+	TASSERT(texit == TASK_EXIT_UNEXPECTED);
+	/* retval is undefined */
+	TPRINTF("OK\n");
+	/* ---- */
+
+	TPRINTF("24 repeated wait\n");
+
+	task_wait_set(&wait, TASK_WAIT_BOTH);
+	rc = dummy_task_spawn(&tid, &wait, STR_DAEMON);
+	TASSERT(rc == EOK);
+
+	TPRINTF("waiting...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == TASK_WAIT_EXIT);
+	TASSERT(retval == EOK);
+	task_kill(tid); /* Terminate daemon */
+	TPRINTF("waiting 2...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
+	//TASSERT(texit == TASK_EXIT_UNEXPECTED); // TODO resolve this in taskman/kernel
+	TPRINTF("OK\n");
+	/* ---- */
+
+	TPRINTF("34 double wait in one\n");
+
+	task_wait_set(&wait, TASK_WAIT_BOTH);
+	rc = dummy_task_spawn(&tid, &wait, STR_JOB_OK);
+	TASSERT(rc == EOK);
+
+	TPRINTF("waiting...");
+	texit = TASK_EXIT_RUNNING; retval = 255;
+	rc = task_wait(&wait, &texit, &retval);
+	TPRINTF("done.\n");
+	TASSERT(rc == EOK);
+	TASSERT(task_wait_get(&wait) == 0);
 	TASSERT(texit == TASK_EXIT_NORMAL);
 	TASSERT(retval == EOK);
