Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision 63f89665fc0283c1661274dc636d5a66e03d48b4)
+++ uspace/lib/c/generic/task.c	(revision 6c39a9074d1bf9a23bf5243a2c35b2a8549f41d3)
@@ -70,16 +70,21 @@
  * loader API.
  *
- * @param path pathname of the binary to execute
- * @param argv command-line arguments
+ * @param path Pathname of the binary to execute.
+ * @param argv Command-line arguments.
+ * @param err  If not NULL, the error value is stored here.
  *
  * @return ID of the newly created task or zero on error.
  *
  */
-task_id_t task_spawn(const char *path, const char *const args[])
+task_id_t task_spawn(const char *path, const char *const args[], int *err)
 {
 	/* Connect to a program loader. */
 	loader_t *ldr = loader_connect();
-	if (ldr == NULL)
+	if (ldr == NULL) {
+		if (err != NULL)
+			*err = EREFUSED;
+		
 		return 0;
+	}
 	
 	/* Get task ID. */
@@ -143,4 +148,8 @@
 	/* Success */
 	free(ldr);
+	
+	if (err != NULL)
+		*err = EOK;
+	
 	return task_id;
 	
@@ -149,4 +158,7 @@
 	loader_abort(ldr);
 	free(ldr);
+	
+	if (err != NULL)
+		*err = rc;
 	
 	return 0;
