Index: uspace/lib/c/generic/ns.c
===================================================================
--- uspace/lib/c/generic/ns.c	(revision 09ab0a9afc9379f1604c0fd75cac2d9287ba022c)
+++ uspace/lib/c/generic/ns.c	(revision 01900b629bbf57a290cd30c16fdaa744836c4c32)
@@ -49,10 +49,11 @@
     async_port_handler_t handler, void *data)
 {
-	async_sess_t *sess = ns_session_get();
-	if (sess == NULL)
-		return EIO;
+	errno_t rc;
+	async_sess_t *sess = ns_session_get(&rc);
+	if (sess == NULL)
+		return rc;
 
 	port_id_t port;
-	errno_t rc = async_create_port(iface, handler, data, &port);
+	rc = async_create_port(iface, handler, data, &port);
 	if (rc != EOK)
 		return rc;
@@ -81,7 +82,8 @@
 	async_set_fallback_port_handler(handler, data);
 
-	async_sess_t *sess = ns_session_get();
-	if (sess == NULL)
-		return EIO;
+	errno_t rc;
+	async_sess_t *sess = ns_session_get(&rc);
+	if (sess == NULL)
+		return rc;
 
 	async_exch_t *exch = async_exchange_begin(sess);
@@ -89,5 +91,5 @@
 	ipc_call_t answer;
 	aid_t req = async_send_1(exch, NS_REGISTER_BROKER, service, &answer);
-	errno_t rc = async_connect_to_me(exch, INTERFACE_ANY, service, 0);
+	rc = async_connect_to_me(exch, INTERFACE_ANY, service, 0);
 
 	async_exchange_end(exch);
@@ -103,7 +105,18 @@
 }
 
-async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3)
-{
-	async_sess_t *sess = ns_session_get();
+/** Connect to a singleton service.
+ *
+ * @param service Singleton service ID.
+ * @param iface   Interface to connect to.
+ * @param arg3    Custom connection argument.
+ * @param rc      Placeholder for return code. Unused if NULL.
+ *
+ * @return New session on success or NULL on error.
+ *
+ */
+async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3,
+    errno_t *rc)
+{
+	async_sess_t *sess = ns_session_get(rc);
 	if (sess == NULL)
 		return NULL;
@@ -114,5 +127,5 @@
 
 	async_sess_t *csess =
-	    async_connect_me_to(exch, iface, service, arg3);
+	    async_connect_me_to(exch, iface, service, arg3, rc);
 	async_exchange_end(exch);
 
@@ -130,8 +143,18 @@
 }
 
+/** Wait and connect to a singleton service.
+ *
+ * @param service Singleton service ID.
+ * @param iface   Interface to connect to.
+ * @param arg3    Custom connection argument.
+ * @param rc      Placeholder for return code. Unused if NULL.
+ *
+ * @return New session on success or NULL on error.
+ *
+ */
 async_sess_t *service_connect_blocking(service_t service, iface_t iface,
-    sysarg_t arg3)
-{
-	async_sess_t *sess = ns_session_get();
+    sysarg_t arg3, errno_t *rc)
+{
+	async_sess_t *sess = ns_session_get(rc);
 	if (sess == NULL)
 		return NULL;
@@ -139,5 +162,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 	async_sess_t *csess =
-	    async_connect_me_to_blocking(exch, iface, service, arg3);
+	    async_connect_me_to_blocking(exch, iface, service, arg3, rc);
 	async_exchange_end(exch);
 
@@ -157,30 +180,31 @@
 errno_t ns_ping(void)
 {
-	async_sess_t *sess = ns_session_get();
+	errno_t rc;
+	async_sess_t *sess = ns_session_get(&rc);
+	if (sess == NULL)
+		return rc;
+
+	async_exch_t *exch = async_exchange_begin(sess);
+	rc = async_req_0_0(exch, NS_PING);
+	async_exchange_end(exch);
+
+	return rc;
+}
+
+errno_t ns_intro(task_id_t id)
+{
+	errno_t rc;
+	async_sess_t *sess = ns_session_get(&rc);
 	if (sess == NULL)
 		return EIO;
 
 	async_exch_t *exch = async_exchange_begin(sess);
-	errno_t rc = async_req_0_0(exch, NS_PING);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t ns_intro(task_id_t id)
-{
-	async_exch_t *exch;
-	async_sess_t *sess = ns_session_get();
-	if (sess == NULL)
-		return EIO;
-
-	exch = async_exchange_begin(sess);
-	errno_t rc = async_req_2_0(exch, NS_ID_INTRO, LOWER32(id), UPPER32(id));
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-async_sess_t *ns_session_get(void)
+	rc = async_req_2_0(exch, NS_ID_INTRO, LOWER32(id), UPPER32(id));
+	async_exchange_end(exch);
+
+	return rc;
+}
+
+async_sess_t *ns_session_get(errno_t *rc)
 {
 	async_exch_t *exch;
@@ -188,5 +212,5 @@
 	if (sess_ns == NULL) {
 		exch = async_exchange_begin(&session_ns);
-		sess_ns = async_connect_me_to(exch, 0, 0, 0);
+		sess_ns = async_connect_me_to(exch, 0, 0, 0, rc);
 		async_exchange_end(exch);
 		if (sess_ns == NULL)
