wet_process: Rearrange fork() if tree to case statement
Matches the safe Xwayland implementation more closely and makes it easier to reuse it. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
8b238905d7
commit
a3175727cb
+23
-22
@@ -408,7 +408,7 @@ weston_client_launch(struct weston_compositor *compositor,
|
|||||||
{
|
{
|
||||||
int sv[2];
|
int sv[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
struct wl_client *client;
|
struct wl_client *client = NULL;
|
||||||
|
|
||||||
weston_log("launching '%s'\n", path);
|
weston_log("launching '%s'\n", path);
|
||||||
|
|
||||||
@@ -420,16 +420,8 @@ weston_client_launch(struct weston_compositor *compositor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == -1) {
|
switch (pid) {
|
||||||
close(sv[0]);
|
case 0:
|
||||||
close(sv[1]);
|
|
||||||
weston_log("weston_client_launch: "
|
|
||||||
"fork failed while launching '%s': %s\n", path,
|
|
||||||
strerror(errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0) {
|
|
||||||
/* Put the client in a new session so it won't catch signals
|
/* Put the client in a new session so it won't catch signals
|
||||||
* intended for the parent. Sharing a session can be
|
* intended for the parent. Sharing a session can be
|
||||||
* confusing when launching weston under gdb, as the ctrl-c
|
* confusing when launching weston under gdb, as the ctrl-c
|
||||||
@@ -439,23 +431,32 @@ weston_client_launch(struct weston_compositor *compositor,
|
|||||||
setsid();
|
setsid();
|
||||||
child_client_exec(sv[1], path);
|
child_client_exec(sv[1], path);
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
}
|
|
||||||
|
|
||||||
close(sv[1]);
|
default:
|
||||||
|
close(sv[1]);
|
||||||
|
client = wl_client_create(compositor->wl_display, sv[0]);
|
||||||
|
if (!client) {
|
||||||
|
close(sv[0]);
|
||||||
|
weston_log("weston_client_launch: "
|
||||||
|
"wl_client_create failed while launching '%s'.\n",
|
||||||
|
path);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
client = wl_client_create(compositor->wl_display, sv[0]);
|
proc->pid = pid;
|
||||||
if (!client) {
|
proc->cleanup = cleanup;
|
||||||
|
wet_watch_process(compositor, proc);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -1:
|
||||||
close(sv[0]);
|
close(sv[0]);
|
||||||
|
close(sv[1]);
|
||||||
weston_log("weston_client_launch: "
|
weston_log("weston_client_launch: "
|
||||||
"wl_client_create failed while launching '%s'.\n",
|
"fork failed while launching '%s': %s\n", path,
|
||||||
path);
|
strerror(errno));
|
||||||
return NULL;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
proc->pid = pid;
|
|
||||||
proc->cleanup = cleanup;
|
|
||||||
wet_watch_process(compositor, proc);
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user