Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 7faabb7f6879c7279c1423c847dfaedf930cff0f)
+++ kernel/generic/src/proc/program.c	(revision adb5fe3a0d41ea1a2ddb715f4235287c3745c43b)
@@ -68,7 +68,8 @@
  * @param as		Address space containing a binary program image.
  * @param entry_addr	Program entry-point address in program address space.
+ * @param name		Name to set for the program's task.
  * @param p		Buffer for storing program information.
  */
-void program_create(as_t *as, uintptr_t entry_addr, program_t *p)
+void program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *p)
 {
 	as_area_t *a;
@@ -82,5 +83,5 @@
 	kernel_uarg->uspace_uarg = NULL;
 	
-	p->task = task_create(as, "app");
+	p->task = task_create(as, name);
 	ASSERT(p->task);
 
@@ -107,4 +108,5 @@
  *
  * @param image_addr	Address of an executable program image.
+ * @param name		Name to set for the program's task.
  * @param p		Buffer for storing program info. If image_addr
  *			points to a loader image, p->task will be set to
@@ -113,5 +115,5 @@
  * @return EOK on success or negative error code.
  */
-int program_create_from_image(void *image_addr, program_t *p)
+int program_create_from_image(void *image_addr, char *name, program_t *p)
 {
 	as_t *as;
@@ -137,5 +139,5 @@
 	}
 
-	program_create(as, ((elf_header_t *) image_addr)->e_entry, p);
+	program_create(as, ((elf_header_t *) image_addr)->e_entry, name, p);
 
 	return EOK;
@@ -144,8 +146,10 @@
 /** Create a task from the program loader image.
  *
- * @param p Buffer for storing program info.
+ * @param p	Buffer for storing program info.
+ * @param name	Name to set for the program's task.
+ *
  * @return EOK on success or negative error code.
  */
-int program_create_loader(program_t *p)
+int program_create_loader(program_t *p, char *name)
 {
 	as_t *as;
@@ -168,5 +172,6 @@
 	}
 
-	program_create(as, ((elf_header_t *) program_loader)->e_entry, p);
+	program_create(as, ((elf_header_t *) program_loader)->e_entry,
+	    name, p);
 
 	return EOK;
@@ -189,9 +194,12 @@
  * to it and stores the phone id into the provided buffer.
  *
- * @param uspace_phone_id Userspace address where to store the phone id.
+ * @param uspace_phone_id	Userspace address where to store the phone id.
+ * @param name			Name to set on the new task (typically the same
+ *				as the command used to execute it).
  *
  * @return 0 on success or an error code from @ref errno.h.
  */
-unative_t sys_program_spawn_loader(int *uspace_phone_id)
+unative_t sys_program_spawn_loader(int *uspace_phone_id, char *uspace_name,
+    size_t name_len)
 {
 	program_t p;
@@ -199,4 +207,5 @@
 	int rc;
 	int phone_id;
+	char namebuf[TASK_NAME_BUFLEN];
 
 	fake_id = 0;
@@ -208,9 +217,24 @@
 		return rc;
 
+	/* Cap length of name and copy it from userspace. */
+
+	if (name_len > THREAD_NAME_BUFLEN - 1)
+		name_len = THREAD_NAME_BUFLEN - 1;
+
+	rc = copy_from_uspace(namebuf, uspace_name, name_len);
+	if (rc != 0)
+		return (unative_t) rc;
+
+	namebuf[name_len] = '\0';
+
+	/* Allocate the phone for communicating with the new task. */
+
 	phone_id = phone_alloc();
 	if (phone_id < 0)
 		return ELIMIT;
 
-	rc = program_create_loader(&p);
+	/* Spawn the new task. */
+
+	rc = program_create_loader(&p, namebuf);
 	if (rc != 0)
 		return rc;
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 7faabb7f6879c7279c1423c847dfaedf930cff0f)
+++ kernel/generic/src/proc/task.c	(revision adb5fe3a0d41ea1a2ddb715f4235287c3745c43b)
@@ -131,5 +131,5 @@
  *
  * @param as		Task's address space.
- * @param name		Symbolic name.
+ * @param name		Symbolic name (a copy is made).
  *
  * @return		New task's structure.
@@ -149,5 +149,8 @@
 	list_initialize(&ta->th_head);
 	ta->as = as;
-	ta->name = name;
+
+	memcpy(ta->name, name, TASK_NAME_BUFLEN);
+	ta->name[TASK_NAME_BUFLEN - 1] = '\0';
+
 	atomic_set(&ta->refcount, 0);
 	atomic_set(&ta->lifecount, 0);
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 7faabb7f6879c7279c1423c847dfaedf930cff0f)
+++ kernel/generic/src/proc/thread.c	(revision adb5fe3a0d41ea1a2ddb715f4235287c3745c43b)
@@ -280,5 +280,5 @@
  * 			call. The task's lock may not be held.
  * @param flags		Thread flags.
- * @param name		Symbolic name.
+ * @param name		Symbolic name (a copy is made).
  * @param uncounted	Thread's accounting doesn't affect accumulated task
  * 			accounting.
@@ -317,4 +317,5 @@
 	
 	memcpy(t->name, name, THREAD_NAME_BUFLEN);
+	t->name[THREAD_NAME_BUFLEN - 1] = '\0';
 	
 	t->thread_code = func;
@@ -716,5 +717,5 @@
 	int rc;
 
-	if (name_len >= THREAD_NAME_BUFLEN)
+	if (name_len > THREAD_NAME_BUFLEN - 1)
 		name_len = THREAD_NAME_BUFLEN - 1;
 
