Fix fd leak to children
This commit is contained in:
parent
a46d22b31f
commit
f4ec61340f
3 changed files with 14 additions and 1 deletions
|
@ -644,6 +644,7 @@ void execp_timer_callback(void *arg)
|
|||
close(pipe_fd_stderr[0]);
|
||||
dup2(pipe_fd_stderr[1], 2); // 2 is stderr
|
||||
close(pipe_fd_stderr[1]);
|
||||
close_all_fds();
|
||||
setpgid(0, 0);
|
||||
execl("/bin/sh", "/bin/sh", "-c", execp->backend->command, NULL);
|
||||
// This should never happen!
|
||||
|
|
|
@ -230,6 +230,7 @@ pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time
|
|||
// Run the command
|
||||
if (dir)
|
||||
chdir(dir);
|
||||
close_all_fds();
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||
fprintf(stderr, "Failed to execlp %s\n", command);
|
||||
#if HAVE_SN
|
||||
|
@ -754,7 +755,8 @@ void get_text_size2(const PangoFontDescription *font,
|
|||
available_height = MAX(0, available_height);
|
||||
Pixmap pmap = XCreatePixmap(server.display, server.root_win, available_height, available_width, server.depth);
|
||||
|
||||
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, pmap, server.visual, available_height, available_width);
|
||||
cairo_surface_t *cs =
|
||||
cairo_xlib_surface_create(server.display, pmap, server.visual, available_height, available_width);
|
||||
cairo_t *c = cairo_create(cs);
|
||||
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
|
@ -848,3 +850,11 @@ gint cmp_ptr(gconstpointer a, gconstpointer b)
|
|||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void close_all_fds()
|
||||
{
|
||||
long maxfd = sysconf(_SC_OPEN_MAX);
|
||||
for (int fd = 3; fd < maxfd; fd++) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ void draw_rect_on_sides(cairo_t *c, double x, double y, double w, double h, doub
|
|||
// Clears the pixmap (with transparent color)
|
||||
void clear_pixmap(Pixmap p, int x, int y, int w, int h);
|
||||
|
||||
void close_all_fds();
|
||||
|
||||
// Appends to the list locations all the directories contained in the environment variable var (split by ":").
|
||||
// Optional suffixes are added to each directory. The suffix arguments MUST end with NULL.
|
||||
// Returns the new value of the list.
|
||||
|
|
Loading…
Reference in a new issue