* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
*
* i3.h: global variables that are used all over i3.
*
extern struct rlimit original_rlimit_core;
/** Whether this version of i3 is a debug build or a release build. */
extern bool debug_build;
+/** The number of file descriptors passed via socket activation. */
+extern int listen_fds;
extern xcb_connection_t *conn;
extern int conn_screen;
/** The last timestamp we got from X11 (timestamps are included in some events
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
*
* main.c: Initialization, main loop
*
/* Whether this version of i3 is a debug build or a release build. */
bool debug_build = false;
+/** The number of file descriptors passed via socket activation. */
+int listen_fds;
+
static int xkb_event_base;
int xkb_current_group;
/* Also handle the UNIX domain sockets passed via socket activation. The
* parameter 1 means "remove the environment variables", we don’t want to
* pass these to child processes. */
- int fds = sd_listen_fds(1);
- if (fds < 0)
+ listen_fds = sd_listen_fds(0);
+ if (listen_fds < 0)
ELOG("socket activation: Error in sd_listen_fds\n");
- else if (fds == 0)
+ else if (listen_fds == 0)
DLOG("socket activation: no sockets passed\n");
else {
- for (int fd = SD_LISTEN_FDS_START; fd < (SD_LISTEN_FDS_START + fds); fd++) {
+ int flags;
+ for (int fd = SD_LISTEN_FDS_START;
+ fd < (SD_LISTEN_FDS_START + listen_fds);
+ fd++) {
DLOG("socket activation: also listening on fd %d\n", fd);
+
+ /* sd_listen_fds() enables FD_CLOEXEC by default.
+ * However, we need to keep the file descriptors open for in-place
+ * restarting, therefore we explicitly disable FD_CLOEXEC. */
+ if ((flags = fcntl(fd, F_GETFD)) < 0 ||
+ fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) < 0) {
+ ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd);
+ }
+
struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
ev_io_start(main_loop, ipc_io);
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
*
* startup.c: Startup notification code. Ensures a startup notification context
* is setup when launching applications. We store the current
*
*/
#include "all.h"
+#include "sd-daemon.h"
#include <sys/types.h>
#include <sys/wait.h>
/* Child process */
setsid();
setrlimit(RLIMIT_CORE, &original_rlimit_core);
+ /* Close all socket activation file descriptors explicitly, we disabled
+ * FD_CLOEXEC to keep them open when restarting i3. */
+ for (int fd = SD_LISTEN_FDS_START;
+ fd < (SD_LISTEN_FDS_START + listen_fds);
+ fd++) {
+ close(fd);
+ }
+ unsetenv("LISTEN_PID");
+ unsetenv("LISTEN_FDS");
if (fork() == 0) {
/* Setup the environment variable(s) */
if (!no_startup_id)
my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
my $reply = $x->get_property_reply($cookie->{sequence});
my $socketpath = $reply->{value};
+ if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") {
+ $socketpath .= '-activation';
+ }
$_cached_socket_path = $socketpath;
return $socketpath;
}
is(scalar @{$ws->{floating_nodes}}, 1, 'precisely one floating node');
cmd 'restart';
-sleep 0.5;
diag('Checking if i3 still lives');
# perform an inplace-restart
cmd 'restart';
-sleep 0.25;
-
does_i3_live;
is($docknode->{rect}->{height}, 20, 'dock node has unchanged height');
cmd 'restart';
-sleep 0.25;
@docked = get_dock_clients;
is(@docked, 1, 'one dock client found');
# perform an inplace-restart
cmd 'restart';
-sleep 0.25;
-
does_i3_live;
is(get_border_style(), '1pixel', 'border style still 1pixel after restart');
sync_with_i3;
cmd 'restart';
-sleep 1;
does_i3_live;
my $old_floating_nodes = scalar @{$__i3_scratch->{floating_nodes}};
cmd 'restart';
-sleep 1;
does_i3_live;
is($focus->[1], $nodes->[1]->{id}, 'second node second in focus stack');
cmd 'restart';
-sleep 1;
does_i3_live;