blob: 5ccf30251eddfb6296532c8f74e49820f0d8ddc3 [file] [log] [blame]
Benjamin Franzkebfeda132012-01-30 14:04:04 +01001/*
2 * Copyright © 2012 Benjamin Franzke
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -07003 * Copyright © 2013 Intel Corporation
Benjamin Franzkebfeda132012-01-30 14:04:04 +01004 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of the copyright holders not be used in
10 * advertising or publicity pertaining to distribution of the software
11 * without specific, written prior permission. The copyright holders make
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
14 *
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 */
23
Daniel Stonec228e232013-05-22 18:03:19 +030024#include "config.h"
25
Benjamin Franzkebfeda132012-01-30 14:04:04 +010026#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29
30#include <errno.h>
Kristian Høgsberg3f495872013-09-18 23:00:17 -070031#include <signal.h>
Benjamin Franzkebfeda132012-01-30 14:04:04 +010032#include <sys/socket.h>
33#include <sys/types.h>
34#include <sys/stat.h>
35#include <sys/uio.h>
Kristian Høgsberg3f495872013-09-18 23:00:17 -070036#include <sys/ioctl.h>
Benjamin Franzkebfeda132012-01-30 14:04:04 +010037#include <fcntl.h>
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070038#include <unistd.h>
Kristian Høgsberg3f495872013-09-18 23:00:17 -070039#include <linux/vt.h>
40#include <linux/kd.h>
41#include <linux/major.h>
Benjamin Franzkebfeda132012-01-30 14:04:04 +010042
Adrian Negreanu908e6d02013-09-27 20:58:45 +030043#ifdef BUILD_DRM_COMPOSITOR
Benjamin Franzkebfeda132012-01-30 14:04:04 +010044#include <xf86drm.h>
Adrian Negreanu908e6d02013-09-27 20:58:45 +030045#endif
Benjamin Franzkebfeda132012-01-30 14:04:04 +010046
47#include "compositor.h"
48#include "launcher-util.h"
David Herrmanncc5b2ed2013-10-22 00:28:09 +020049#include "logind-util.h"
Benjamin Franzkebfeda132012-01-30 14:04:04 +010050#include "weston-launch.h"
51
Kristian Høgsberg3f495872013-09-18 23:00:17 -070052#define DRM_MAJOR 226
53
54#ifndef KDSKBMUTE
55#define KDSKBMUTE 0x4B51
56#endif
57
Kristian Høgsberg9e140912012-04-10 01:26:18 -040058union cmsg_data { unsigned char b[4]; int fd; };
59
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070060struct weston_launcher {
David Herrmanncc5b2ed2013-10-22 00:28:09 +020061 struct weston_logind *logind;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070062 struct weston_compositor *compositor;
63 int fd;
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -070064 struct wl_event_source *source;
Kristian Høgsberg3f495872013-09-18 23:00:17 -070065
66 int kb_mode, tty, drm_fd;
67 struct wl_event_source *vt_source;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070068};
69
Kristian Høgsberg57a10e42013-10-01 15:37:09 -070070#ifdef BUILD_DRM_COMPOSITOR
71static int
72drm_drop_master(int drm_fd)
73{
Kristian Høgsberg891a16d2013-10-14 13:59:53 -070074 return drmDropMaster(drm_fd);
Kristian Høgsberg57a10e42013-10-01 15:37:09 -070075}
76static int
77drm_set_master(int drm_fd)
78{
Kristian Høgsberg891a16d2013-10-14 13:59:53 -070079 return drmSetMaster(drm_fd);
Kristian Høgsberg57a10e42013-10-01 15:37:09 -070080}
Tomeu Vizoso0b12db52013-10-09 11:30:57 +020081static int
Kristian Høgsberg876c75f2013-10-14 13:57:44 -070082drm_is_master(int drm_fd)
Tomeu Vizoso0b12db52013-10-09 11:30:57 +020083{
84 drm_magic_t magic;
Kristian Høgsberg891a16d2013-10-14 13:59:53 -070085
86 return drmGetMagic(drm_fd, &magic) == 0 &&
87 drmAuthMagic(drm_fd, magic) == 0;
Tomeu Vizoso0b12db52013-10-09 11:30:57 +020088}
Kristian Høgsberg57a10e42013-10-01 15:37:09 -070089#else
90static int drm_drop_master(int drm_fd) {return 0;}
91static int drm_set_master(int drm_fd) {return 0;}
Kristian Høgsberg876c75f2013-10-14 13:57:44 -070092static int drm_is_master(int drm_fd) {return 1;}
Kristian Høgsberg57a10e42013-10-01 15:37:09 -070093#endif
94
Benjamin Franzkebfeda132012-01-30 14:04:04 +010095int
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -070096weston_launcher_open(struct weston_launcher *launcher,
Benjamin Franzkebfeda132012-01-30 14:04:04 +010097 const char *path, int flags)
98{
Kristian Høgsberg3f495872013-09-18 23:00:17 -070099 int n, fd, ret = -1;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100100 struct msghdr msg;
101 struct cmsghdr *cmsg;
102 struct iovec iov;
Kristian Høgsberg9e140912012-04-10 01:26:18 -0400103 union cmsg_data *data;
104 char control[CMSG_SPACE(sizeof data->fd)];
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100105 ssize_t len;
106 struct weston_launcher_open *message;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700107 struct stat s;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100108
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200109 if (launcher->logind)
110 return weston_logind_open(launcher->logind, path, flags);
111
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700112 if (launcher->fd == -1) {
113 fd = open(path, flags | O_CLOEXEC);
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700114 if (fd == -1)
115 return -1;
116
117 if (fstat(fd, &s) == -1) {
118 close(fd);
119 return -1;
120 }
121
Kristian Høgsberg57a10e42013-10-01 15:37:09 -0700122 if (major(s.st_rdev) == DRM_MAJOR) {
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700123 launcher->drm_fd = fd;
Kristian Høgsberg876c75f2013-10-14 13:57:44 -0700124 if (!drm_is_master(fd)) {
Kristian Høgsberg1468e602013-10-02 10:49:05 -0700125 weston_log("drm fd not master\n");
Kristian Høgsberg57a10e42013-10-01 15:37:09 -0700126 close(fd);
127 return -1;
128 }
129 }
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700130
131 return fd;
132 }
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100133
134 n = sizeof(*message) + strlen(path) + 1;
135 message = malloc(n);
136 if (!message)
137 return -1;
138
139 message->header.opcode = WESTON_LAUNCHER_OPEN;
140 message->flags = flags;
141 strcpy(message->path, path);
142
143 do {
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700144 len = send(launcher->fd, message, n, 0);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100145 } while (len < 0 && errno == EINTR);
Kristian Høgsbergba25bd72012-04-10 01:31:09 -0400146 free(message);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100147
148 memset(&msg, 0, sizeof msg);
149 iov.iov_base = &ret;
150 iov.iov_len = sizeof ret;
151 msg.msg_iov = &iov;
152 msg.msg_iovlen = 1;
153 msg.msg_control = control;
154 msg.msg_controllen = sizeof control;
155
156 do {
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700157 len = recvmsg(launcher->fd, &msg, MSG_CMSG_CLOEXEC);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100158 } while (len < 0 && errno == EINTR);
159
160 if (len != sizeof ret ||
161 ret < 0)
Kristian Høgsbergba25bd72012-04-10 01:31:09 -0400162 return -1;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100163
164 cmsg = CMSG_FIRSTHDR(&msg);
165 if (!cmsg ||
166 cmsg->cmsg_level != SOL_SOCKET ||
167 cmsg->cmsg_type != SCM_RIGHTS) {
168 fprintf(stderr, "invalid control message\n");
Kristian Høgsbergba25bd72012-04-10 01:31:09 -0400169 return -1;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100170 }
171
Kristian Høgsberg9e140912012-04-10 01:26:18 -0400172 data = (union cmsg_data *) CMSG_DATA(cmsg);
173 if (data->fd == -1) {
Martin Andersson566b4642013-02-13 00:11:12 +0100174 fprintf(stderr, "missing drm fd in socket request\n");
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100175 return -1;
176 }
177
Kristian Høgsbergba25bd72012-04-10 01:31:09 -0400178 return data->fd;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100179}
180
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700181void
David Herrmanne461f852013-10-22 00:28:08 +0200182weston_launcher_close(struct weston_launcher *launcher, int fd)
183{
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200184 if (launcher->logind)
185 return weston_logind_close(launcher->logind, fd);
186
David Herrmanne461f852013-10-22 00:28:08 +0200187 close(fd);
188}
189
190void
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700191weston_launcher_restore(struct weston_launcher *launcher)
192{
193 struct vt_mode mode = { 0 };
194
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200195 if (launcher->logind)
196 return weston_logind_restore(launcher->logind);
197
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700198 if (ioctl(launcher->tty, KDSKBMUTE, 0) &&
199 ioctl(launcher->tty, KDSKBMODE, launcher->kb_mode))
200 weston_log("failed to restore kb mode: %m\n");
201
202 if (ioctl(launcher->tty, KDSETMODE, KD_TEXT))
203 weston_log("failed to set KD_TEXT mode on tty: %m\n");
204
Kristian Høgsberga28ba552013-10-30 16:27:16 -0700205 /* We have to drop master before we switch the VT back in
206 * VT_AUTO, so we don't risk switching to a VT with another
207 * display server, that will then fail to set drm master. */
208 drm_drop_master(launcher->drm_fd);
209
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700210 mode.mode = VT_AUTO;
211 if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
212 weston_log("could not reset vt handling\n");
213}
214
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700215static int
216weston_launcher_data(int fd, uint32_t mask, void *data)
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100217{
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700218 struct weston_launcher *launcher = data;
219 int len, ret;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100220
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700221 if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) {
222 weston_log("launcher socket closed, exiting\n");
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700223 /* Normally the weston-launch will reset the tty, but
224 * in this case it died or something, so do it here so
225 * we don't end up with a stuck vt. */
226 weston_launcher_restore(launcher);
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700227 exit(-1);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100228 }
229
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100230 do {
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700231 len = recv(launcher->fd, &ret, sizeof ret, 0);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100232 } while (len < 0 && errno == EINTR);
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100233
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700234 switch (ret) {
235 case WESTON_LAUNCHER_ACTIVATE:
236 launcher->compositor->session_active = 1;
237 wl_signal_emit(&launcher->compositor->session_signal,
238 launcher->compositor);
239 break;
240 case WESTON_LAUNCHER_DEACTIVATE:
241 launcher->compositor->session_active = 0;
242 wl_signal_emit(&launcher->compositor->session_signal,
243 launcher->compositor);
244 break;
245 default:
246 weston_log("unexpected event from weston-launch\n");
247 break;
248 }
249
250 return 1;
Benjamin Franzkebfeda132012-01-30 14:04:04 +0100251}
252
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700253static int
254vt_handler(int signal_number, void *data)
255{
256 struct weston_launcher *launcher = data;
257 struct weston_compositor *compositor = launcher->compositor;
258
259 if (compositor->session_active) {
260 compositor->session_active = 0;
261 wl_signal_emit(&compositor->session_signal, compositor);
Adrian Negreanu908e6d02013-09-27 20:58:45 +0300262 drm_drop_master(launcher->drm_fd);
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700263 ioctl(launcher->tty, VT_RELDISP, 1);
264 } else {
265 ioctl(launcher->tty, VT_RELDISP, VT_ACKACQ);
Adrian Negreanu908e6d02013-09-27 20:58:45 +0300266 drm_set_master(launcher->drm_fd);
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700267 compositor->session_active = 1;
268 wl_signal_emit(&compositor->session_signal, compositor);
269 }
270
271 return 1;
272}
273
274static int
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700275setup_tty(struct weston_launcher *launcher, int tty)
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700276{
277 struct wl_event_loop *loop;
278 struct vt_mode mode = { 0 };
279 struct stat buf;
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700280 char tty_device[32] ="<stdin>";
281 int ret, kd_mode;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700282
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700283 if (tty == 0) {
Kristian Høgsberg325390e2013-10-09 11:03:39 -0700284 launcher->tty = dup(tty);
285 if (launcher->tty == -1) {
286 weston_log("couldn't dup stdin: %m\n");
287 return -1;
288 }
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700289 } else {
290 snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty);
291 launcher->tty = open(tty_device, O_RDWR | O_CLOEXEC);
292 if (launcher->tty == -1) {
293 weston_log("couldn't open tty %s: %m\n", tty_device);
294 return -1;
295 }
296 }
297
298 if (fstat(launcher->tty, &buf) == -1 ||
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700299 major(buf.st_rdev) != TTY_MAJOR || minor(buf.st_rdev) == 0) {
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700300 weston_log("%s not a vt\n", tty_device);
Kristian Høgsberg19ec77a2013-10-01 12:54:55 -0700301 weston_log("if running weston from ssh, "
302 "use --tty to specify a tty\n");
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700303 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700304 }
305
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700306 ret = ioctl(launcher->tty, KDGETMODE, &kd_mode);
307 if (ret) {
308 weston_log("failed to get VT mode: %m\n");
309 return -1;
310 }
311 if (kd_mode != KD_TEXT) {
312 weston_log("%s is already in graphics mode, "
313 "is another display server running?\n", tty_device);
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700314 goto err_close;
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700315 }
316
Kristian Høgsberg74b0d722013-10-09 13:10:42 -0700317 ioctl(launcher->tty, VT_ACTIVATE, minor(buf.st_rdev));
318 ioctl(launcher->tty, VT_WAITACTIVE, minor(buf.st_rdev));
Kristian Høgsberg6ff3ff52013-10-02 10:53:33 -0700319
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700320 if (ioctl(launcher->tty, KDGKBMODE, &launcher->kb_mode)) {
321 weston_log("failed to read keyboard mode: %m\n");
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700322 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700323 }
324
325 if (ioctl(launcher->tty, KDSKBMUTE, 1) &&
326 ioctl(launcher->tty, KDSKBMODE, K_OFF)) {
327 weston_log("failed to set K_OFF keyboard mode: %m\n");
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700328 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700329 }
330
331 ret = ioctl(launcher->tty, KDSETMODE, KD_GRAPHICS);
332 if (ret) {
333 weston_log("failed to set KD_GRAPHICS mode on tty: %m\n");
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700334 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700335 }
336
337 mode.mode = VT_PROCESS;
338 mode.relsig = SIGUSR1;
339 mode.acqsig = SIGUSR1;
340 if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0) {
341 weston_log("failed to take control of vt handling\n");
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700342 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700343 }
344
345 loop = wl_display_get_event_loop(launcher->compositor->wl_display);
346 launcher->vt_source =
347 wl_event_loop_add_signal(loop, SIGUSR1, vt_handler, launcher);
348 if (!launcher->vt_source)
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700349 goto err_close;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700350
351 return 0;
Kristian Høgsberg4a74d5a2013-10-09 11:19:11 -0700352
353 err_close:
354 close(launcher->tty);
355 return -1;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700356}
357
358int
359weston_launcher_activate_vt(struct weston_launcher *launcher, int vt)
360{
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200361 if (launcher->logind)
362 return weston_logind_activate_vt(launcher->logind, vt);
363
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700364 return ioctl(launcher->tty, VT_ACTIVATE, vt);
365}
366
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700367struct weston_launcher *
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200368weston_launcher_connect(struct weston_compositor *compositor, int tty,
369 const char *seat_id)
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700370{
371 struct weston_launcher *launcher;
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700372 struct wl_event_loop *loop;
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200373 int r;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700374
375 launcher = malloc(sizeof *launcher);
376 if (launcher == NULL)
377 return NULL;
378
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200379 launcher->logind = NULL;
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700380 launcher->compositor = compositor;
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700381 launcher->drm_fd = -1;
382 launcher->fd = weston_environment_get_fd("WESTON_LAUNCHER_SOCK");
383 if (launcher->fd != -1) {
384 launcher->tty = weston_environment_get_fd("WESTON_TTY_FD");
385 loop = wl_display_get_event_loop(compositor->wl_display);
386 launcher->source = wl_event_loop_add_fd(loop, launcher->fd,
387 WL_EVENT_READABLE,
388 weston_launcher_data,
389 launcher);
390 if (launcher->source == NULL) {
391 free(launcher);
392 return NULL;
393 }
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700394 } else {
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200395 r = weston_logind_connect(&launcher->logind, compositor,
396 seat_id, tty);
397 if (r < 0) {
398 launcher->logind = NULL;
399 if (geteuid() == 0) {
400 if (setup_tty(launcher, tty) == -1) {
401 free(launcher);
402 return NULL;
403 }
404 } else {
405 free(launcher);
406 return NULL;
407 }
408 }
Kristian Høgsberg1eb482d2013-09-17 22:15:37 -0700409 }
410
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700411 return launcher;
412}
413
414void
415weston_launcher_destroy(struct weston_launcher *launcher)
416{
Kristian Høgsbergd4c1cd72013-10-22 13:19:23 -0700417 if (launcher->logind) {
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200418 weston_logind_destroy(launcher->logind);
Kristian Høgsbergd4c1cd72013-10-22 13:19:23 -0700419 } else if (launcher->fd != -1) {
Kristian Høgsberg3f495872013-09-18 23:00:17 -0700420 close(launcher->fd);
421 wl_event_source_remove(launcher->source);
422 } else {
423 weston_launcher_restore(launcher);
424 wl_event_source_remove(launcher->vt_source);
425 }
426
David Herrmanncc5b2ed2013-10-22 00:28:09 +0200427 if (launcher->tty >= 0)
428 close(launcher->tty);
429
Kristian Høgsberg05ad1e42013-09-17 14:41:03 -0700430 free(launcher);
431}