Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Resume all processes on SIGUSR1 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pkg_check_modules (GLIB REQUIRED glib-2.0)
pkg_check_modules (WNCK REQUIRED libwnck-3.0)

add_definitions (-DWNCK_I_KNOW_THIS_IS_UNSTABLE
-D_POSIX_SOURCE)
-D_POSIX_SOURCE
-D_DEFAULT_SOURCE)

add_compile_options (${GLIB_CFLAGS} ${WNCK_CFLAGS})

Expand Down
24 changes: 17 additions & 7 deletions src/xsuspender.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ xsus_window_suspend (WnckWindow *window)
}


void
xsus_resume_all ()
{
g_debug ("Resuming all windows ...");
GSList *l = suspended_entries;
while (l) {
WindowEntry *entry = l->data;
l = l->next;
xsus_signal_continue (entry);
}
}


int
xsus_init ()
{
Expand All @@ -174,6 +187,9 @@ xsus_init ()

xsus_init_event_handlers ();

// Install SIGUSR1 signal handler that resumes all suspended processes
signal (SIGUSR1, xsus_resume_all);

// Install exit signal handlers to exit gracefully
signal (SIGINT, xsus_exit);
signal (SIGTERM, xsus_exit);
Expand All @@ -200,13 +216,7 @@ cleanup ()
wnck_shutdown ();

// Resume processes we have suspended; deallocate window entries
GSList *l = suspended_entries;
while (l) {
WindowEntry *entry = l->data;
l = l->next;
xsus_signal_continue (entry);
}

xsus_resume_all ();
for (GSList *e = queued_entries; e; e = e->next)
xsus_window_entry_free (e->data);

Expand Down
1 change: 1 addition & 0 deletions src/xsuspender.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ gboolean xsus_signal_continue (WindowEntry *entry);
void xsus_window_entry_enqueue (WindowEntry *entry, unsigned delay);
void xsus_window_suspend (WnckWindow *window);
void xsus_window_resume (WnckWindow *window);
void xsus_resume_all ();
int xsus_init ();
void xsus_exit ();

Expand Down