2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <gtk/gtkmain.h>
28 #include <gtk/gtkrc.h>
37 #include <sys/types.h>
40 #ifdef HAVE_STARTUP_NOTIFICATION
41 # define SN_API_NOT_YET_FROZEN
42 # include <libsn/sn-launchee.h>
43 # include <gdk/gdkx.h>
48 # include "passphrase.h"
54 #include "mainwindow.h"
55 #include "folderview.h"
56 #include "summaryview.h"
57 #include "prefs_common.h"
58 #include "prefs_account.h"
59 #include "prefs_actions.h"
60 #include "prefs_ext_prog.h"
61 #include "prefs_fonts.h"
62 #include "prefs_msg_colors.h"
63 #include "prefs_spelling.h"
64 #include "prefs_themes.h"
65 #include "prefs_wrapping.h"
66 #include "prefs_display_header.h"
71 #include "manage_window.h"
72 #include "alertpanel.h"
73 #include "statusbar.h"
74 #include "addressbook.h"
82 #include "prefs_toolbar.h"
102 #ifdef HAVE_STARTUP_NOTIFICATION
103 static SnLauncheeContext *sn_context = NULL;
104 static SnDisplay *sn_display = NULL;
107 static gint lock_socket = -1;
108 static gint lock_socket_tag = 0;
112 ONLINE_MODE_DONT_CHANGE,
117 static struct RemoteCmd {
119 gboolean receive_all;
121 const gchar *compose_mailto;
122 GPtrArray *attach_files;
124 gboolean status_full;
125 GPtrArray *status_folders;
126 GPtrArray *status_full_folders;
133 static void parse_cmd_opt(int argc, char *argv[]);
135 static gint prohibit_duplicate_launch (void);
136 static gchar * get_crashfile_name (void);
137 static gint lock_socket_remove (void);
138 static void lock_socket_input_cb (gpointer data,
140 GdkInputCondition condition);
144 gchar *get_socket_name (void);
147 static void open_compose_new (const gchar *address,
148 GPtrArray *attach_files);
150 static void send_queue (void);
151 static void initial_processing (FolderItem *item, gpointer data);
152 static void quit_signal_handler (int sig);
153 static void install_basic_sighandlers (void);
154 static void exit_sylpheed (MainWindow *mainwin);
158 _("File `%s' already exists.\n"
159 "Can't create folder.")
162 #define MAKE_DIR_IF_NOT_EXIST(dir) \
164 if (!is_dir_exist(dir)) { \
165 if (is_file_exist(dir)) { \
167 (_("File `%s' already exists.\n" \
168 "Can't create folder."), \
172 if (make_dir(dir) < 0) \
177 static MainWindow *static_mainwindow;
179 #ifdef HAVE_STARTUP_NOTIFICATION
180 static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
182 gdk_error_trap_push();
185 static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
187 gdk_error_trap_pop();
190 static void startup_notification_complete(gboolean with_window)
193 GtkWidget *hack = NULL;
196 /* this is needed to make the startup notification leave,
197 * if we have been launched from a menu.
198 * We have to display a window, so let it be very little */
199 hack = gtk_window_new(GTK_WINDOW_POPUP);
200 gtk_widget_set_uposition(hack, 0, 0);
201 gtk_widget_set_usize(hack, 1, 1);
202 gtk_widget_show(hack);
205 xdisplay = GDK_DISPLAY();
206 sn_display = sn_display_new(xdisplay,
209 sn_context = sn_launchee_context_new_from_environment(sn_display,
210 DefaultScreen(xdisplay));
212 if (sn_context != NULL)
214 sn_launchee_context_complete(sn_context);
215 sn_launchee_context_unref(sn_context);
216 sn_display_unref(sn_display);
219 #endif /* HAVE_STARTUP_NOTIFICATION */
221 void sylpheed_gtk_idle(void)
223 while(gtk_events_pending())
224 gtk_main_iteration();
227 int main(int argc, char *argv[])
231 FolderView *folderview;
233 if (!sylpheed_init(&argc, &argv)) {
237 prog_version = PROG_VERSION;
239 argv0 = g_strdup(argv[0]);
242 parse_cmd_opt(argc, argv);
247 gtk_init(&argc, &argv);
248 crash_main(cmd.crash_params);
251 crash_install_handlers();
253 install_basic_sighandlers();
255 /* check and create unix domain socket */
256 lock_socket = prohibit_duplicate_launch();
257 if (lock_socket < 0) {
258 #ifdef HAVE_STARTUP_NOTIFICATION
259 if(gtk_init_check(&argc, &argv))
260 startup_notification_complete(TRUE);
264 if (cmd.status || cmd.status_full) {
265 puts("0 Sylpheed not running.");
266 lock_socket_remove();
271 gtk_init(&argc, &argv);
274 gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
275 gtk_widget_set_default_visual(gdk_rgb_get_visual());
277 #if USE_THREADS || USE_LDAP
279 if (!g_thread_supported())
280 g_error(_("g_thread is not supported by glib.\n"));
283 /* parse gtkrc files */
284 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
286 gtk_rc_parse(userrc);
288 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
289 G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
290 gtk_rc_parse(userrc);
292 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
293 gtk_rc_parse(userrc);
296 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
297 gtk_accel_map_load (userrc);
300 gtk_settings_set_long_property(gtk_settings_get_default(),
301 "gtk-can-change-accels",
302 (glong)TRUE, "XProperty");
304 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
306 MAKE_DIR_IF_NOT_EXIST(RC_DIR);
307 MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
308 MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
309 MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
310 MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
311 MAKE_DIR_IF_NOT_EXIST(RC_DIR G_DIR_SEPARATOR_S "uidl");
313 set_log_file(RC_DIR G_DIR_SEPARATOR_S "sylpheed.log");
315 folder_system_init();
317 prefs_common_read_config();
321 prefs_ext_prog_init();
322 prefs_wrapping_init();
323 prefs_msg_colors_init();
325 gtkaspell_checkers_init();
326 prefs_spelling_init();
329 sock_set_io_timeout(prefs_common.io_timeout_secs);
331 prefs_actions_read_config();
332 prefs_display_header_read_config();
333 /* prefs_filtering_read_config(); */
334 addressbook_read_file();
335 renderer_read_config();
339 folderview_initialize();
344 mainwin = main_window_create
345 (prefs_common.sep_folder | prefs_common.sep_msg << 1);
346 folderview = mainwin->folderview;
348 /* register the callback of unix domain socket input */
349 lock_socket_tag = gdk_input_add(lock_socket,
350 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
351 lock_socket_input_cb,
354 account_read_config_all();
356 if (folder_read_list() < 0) {
357 if (!run_wizard(mainwin, TRUE))
362 if (!account_get_list()) {
363 if (!run_wizard(mainwin, FALSE))
365 account_read_config_all();
366 if(!account_get_list())
367 exit_sylpheed(mainwin);
370 account_set_missing_folder();
371 folder_set_missing_folders();
372 folderview_set(folderview);
374 prefs_matcher_read_config();
376 /* make one all-folder processing before using sylpheed */
377 folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
379 /* if Sylpheed crashed, rebuild caches */
380 if (!cmd.crash && is_file_exist(get_crashfile_name())) {
381 debug_print("Sylpheed crashed, checking for new messages in local folders\n");
382 folderview_check_new(NULL);
384 /* make the crash-indicator file */
385 str_write_to_file("foo", get_crashfile_name());
387 addressbook_read_file();
389 inc_autocheck_timer_init(mainwin);
391 /* ignore SIGPIPE signal for preventing sudden death of program */
392 signal(SIGPIPE, SIG_IGN);
394 if (cmd.online_mode == ONLINE_MODE_OFFLINE)
395 main_window_toggle_work_offline(mainwin, TRUE);
396 if (cmd.online_mode == ONLINE_MODE_ONLINE)
397 main_window_toggle_work_offline(mainwin, FALSE);
400 inc_all_account_mail(mainwin, FALSE,
401 prefs_common.newmail_notify_manu);
402 else if (prefs_common.chk_on_startup)
403 inc_all_account_mail(mainwin, TRUE,
404 prefs_common.newmail_notify_manu);
405 else if (cmd.receive)
406 inc_mail(mainwin, prefs_common.newmail_notify_manu);
408 gtk_widget_grab_focus(folderview->ctree);
411 open_compose_new(cmd.compose_mailto, cmd.attach_files);
412 if (cmd.attach_files) {
413 ptr_array_free_strings(cmd.attach_files);
414 g_ptr_array_free(cmd.attach_files, TRUE);
415 cmd.attach_files = NULL;
419 if (cmd.status_folders) {
420 g_ptr_array_free(cmd.status_folders, TRUE);
421 cmd.status_folders = NULL;
423 if (cmd.status_full_folders) {
424 g_ptr_array_free(cmd.status_full_folders, TRUE);
425 cmd.status_full_folders = NULL;
428 sylpheed_register_idle_function(sylpheed_gtk_idle);
430 prefs_toolbar_init();
432 plugin_load_all("GTK2");
434 static_mainwindow = mainwin;
436 #ifdef HAVE_STARTUP_NOTIFICATION
437 startup_notification_complete(FALSE);
441 exit_sylpheed(mainwin);
446 static void save_all_caches(FolderItem *item, gpointer data)
450 folder_item_write_cache(item);
453 static void exit_sylpheed(MainWindow *mainwin)
457 debug_print("shutting down\n");
459 inc_autocheck_timer_remove();
461 if (prefs_common.clean_on_exit)
462 main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
464 /* save prefs for opened folder */
465 if(mainwin->folderview->opened)
469 item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
470 summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
473 /* save all state before exiting */
475 folder_func_to_all_folders(save_all_caches, NULL);
477 main_window_get_size(mainwin);
478 main_window_get_position(mainwin);
479 prefs_common_write_config();
480 account_write_config_all();
481 addressbook_export_to_file();
483 filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
484 gtk_accel_map_save(filename);
487 /* delete temporary files */
488 remove_all_files(get_mime_tmp_dir());
492 /* delete crashfile */
494 unlink(get_crashfile_name());
496 lock_socket_remove();
498 main_window_destroy(mainwin);
500 plugin_unload_all("GTK2");
502 prefs_toolbar_done();
504 addressbook_destroy();
508 prefs_ext_prog_done();
509 prefs_wrapping_done();
510 prefs_msg_colors_done();
512 prefs_spelling_done();
513 gtkaspell_checkers_quit();
519 static void parse_cmd_opt(int argc, char *argv[])
523 for (i = 1; i < argc; i++) {
524 if (!strncmp(argv[i], "--receive-all", 13))
525 cmd.receive_all = TRUE;
526 else if (!strncmp(argv[i], "--receive", 9))
528 else if (!strncmp(argv[i], "--compose", 9)) {
529 const gchar *p = argv[i + 1];
532 cmd.compose_mailto = NULL;
533 if (p && *p != '\0' && *p != '-') {
534 if (!strncmp(p, "mailto:", 7))
535 cmd.compose_mailto = p + 7;
537 cmd.compose_mailto = p;
540 } else if (!strncmp(argv[i], "--attach", 8)) {
541 const gchar *p = argv[i + 1];
544 while (p && *p != '\0' && *p != '-') {
545 if (!cmd.attach_files)
546 cmd.attach_files = g_ptr_array_new();
547 if (*p != G_DIR_SEPARATOR)
548 file = g_strconcat(sylpheed_get_startup_dir(),
553 g_ptr_array_add(cmd.attach_files, file);
557 } else if (!strncmp(argv[i], "--send", 6)) {
559 } else if (!strncmp(argv[i], "--version", 9)) {
560 puts("Sylpheed version " VERSION);
562 } else if (!strncmp(argv[i], "--status-full", 13)) {
563 const gchar *p = argv[i + 1];
565 cmd.status_full = TRUE;
566 while (p && *p != '\0' && *p != '-') {
567 if (!cmd.status_full_folders)
568 cmd.status_full_folders =
570 g_ptr_array_add(cmd.status_full_folders,
575 } else if (!strncmp(argv[i], "--status", 8)) {
576 const gchar *p = argv[i + 1];
579 while (p && *p != '\0' && *p != '-') {
580 if (!cmd.status_folders)
581 cmd.status_folders = g_ptr_array_new();
582 g_ptr_array_add(cmd.status_folders,
587 } else if (!strncmp(argv[i], "--online", 8)) {
588 cmd.online_mode = ONLINE_MODE_ONLINE;
589 } else if (!strncmp(argv[i], "--offline", 9)) {
590 cmd.online_mode = ONLINE_MODE_OFFLINE;
591 } else if (!strncmp(argv[i], "--help", 6)) {
592 g_print(_("Usage: %s [OPTION]...\n"),
593 g_basename(argv[0]));
595 puts(_(" --compose [address] open composition window"));
596 puts(_(" --attach file1 [file2]...\n"
597 " open composition window with specified files\n"
599 puts(_(" --receive receive new messages"));
600 puts(_(" --receive-all receive new messages of all accounts"));
601 puts(_(" --send send all queued messages"));
602 puts(_(" --status [folder]... show the total number of messages"));
603 puts(_(" --status-full [folder]...\n"
604 " show the status of each folder"));
605 puts(_(" --online switch to online mode"));
606 puts(_(" --offline switch to offline mode"));
607 puts(_(" --debug debug mode"));
608 puts(_(" --help display this help and exit"));
609 puts(_(" --version output version information and exit"));
610 puts(_(" --config-dir output configuration directory"));
613 } else if (!strncmp(argv[i], "--crash", 7)) {
615 cmd.crash_params = g_strdup(argv[i + 1]);
617 } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
624 if (cmd.attach_files && cmd.compose == FALSE) {
626 cmd.compose_mailto = NULL;
630 static gint get_queued_message_num(void)
634 queue = folder_get_default_queue();
635 if (!queue) return -1;
637 folder_item_scan(queue);
638 return queue->total_msgs;
641 static void initial_processing(FolderItem *item, gpointer data)
643 MainWindow *mainwin = (MainWindow *)data;
646 g_return_if_fail(item);
647 buf = g_strdup_printf(_("Processing (%s)..."),
650 : _("top level folder"));
651 debug_print("%s\n", buf);
654 main_window_cursor_wait(mainwin);
656 if (item->prefs->enable_processing)
657 folder_item_apply_processing(item);
659 debug_print("done.\n");
660 STATUSBAR_POP(mainwin);
661 main_window_cursor_normal(mainwin);
664 static void draft_all_messages(void)
666 GList *compose_list = compose_get_compose_list();
670 for (elem = compose_list; elem != NULL && elem->data != NULL;
672 Compose *c = (Compose*)elem->data;
678 gboolean clean_quit(gpointer data)
680 static gboolean firstrun = TRUE;
686 /*!< Good idea to have the main window stored in a
687 * static variable so we can check that variable
688 * to see if we're really allowed to do things
689 * that actually the spawner is supposed to
690 * do (like: sending mail, composing messages).
691 * Because, really, if we're the spawnee, and
692 * we touch GTK stuff, we're hosed. See the
695 /* FIXME: Use something else to signal that we're
696 * in the original spawner, and not in a spawned
698 if (!static_mainwindow)
701 draft_all_messages();
703 exit_sylpheed(static_mainwindow);
709 void app_will_exit(GtkWidget *widget, gpointer data)
711 MainWindow *mainwin = data;
713 if (compose_get_compose_list()) {
714 gint val = alertpanel(_("Really quit?"),
715 _("Composing message exists."),
716 _("Draft them"), _("Discard them"), _("Don't quit"));
720 case G_ALERTALTERNATE:
723 draft_all_messages();
726 manage_window_focus_in(mainwin->window, NULL, NULL);
729 if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
730 if (alertpanel(_("Queued messages"),
731 _("Some unsent messages are queued. Exit now?"),
732 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
734 manage_window_focus_in(mainwin->window, NULL, NULL);
740 * CLAWS: want this public so crash dialog can delete the
746 gchar *get_socket_name(void)
748 static gchar *filename = NULL;
750 if (filename == NULL) {
751 filename = g_strdup_printf("%s%csylpheed-%d",
752 g_get_tmp_dir(), G_DIR_SEPARATOR,
759 static gchar *get_crashfile_name(void)
761 static gchar *filename = NULL;
763 if (filename == NULL) {
764 filename = g_strdup_printf("%s%csylpheed-crashed",
765 get_tmp_dir(), G_DIR_SEPARATOR);
771 static gint prohibit_duplicate_launch(void)
776 path = get_socket_name();
777 uxsock = fd_connect_unix(path);
780 return fd_open_unix(path);
783 /* remote command mode */
785 debug_print("another Sylpheed is already running.\n");
788 fd_write_all(uxsock, "receive_all\n", 12);
789 else if (cmd.receive)
790 fd_write_all(uxsock, "receive\n", 8);
791 else if (cmd.compose && cmd.attach_files) {
792 gchar *str, *compose_str;
795 if (cmd.compose_mailto)
796 compose_str = g_strdup_printf("compose_attach %s\n",
799 compose_str = g_strdup("compose_attach\n");
801 fd_write_all(uxsock, compose_str, strlen(compose_str));
804 for (i = 0; i < cmd.attach_files->len; i++) {
805 str = g_ptr_array_index(cmd.attach_files, i);
806 fd_write_all(uxsock, str, strlen(str));
807 fd_write_all(uxsock, "\n", 1);
810 fd_write_all(uxsock, ".\n", 2);
811 } else if (cmd.compose) {
814 if (cmd.compose_mailto)
815 compose_str = g_strdup_printf
816 ("compose %s\n", cmd.compose_mailto);
818 compose_str = g_strdup("compose\n");
820 fd_write_all(uxsock, compose_str, strlen(compose_str));
822 } else if (cmd.send) {
823 fd_write_all(uxsock, "send\n", 5);
824 } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
825 fd_write(uxsock, "online\n", 6);
826 } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
827 fd_write(uxsock, "offline\n", 7);
828 } else if (cmd.status || cmd.status_full) {
831 const gchar *command;
835 command = cmd.status_full ? "status-full\n" : "status\n";
836 folders = cmd.status_full ? cmd.status_full_folders :
839 fd_write_all(uxsock, command, strlen(command));
840 for (i = 0; folders && i < folders->len; ++i) {
841 folder = g_ptr_array_index(folders, i);
842 fd_write_all(uxsock, folder, strlen(folder));
843 fd_write_all(uxsock, "\n", 1);
845 fd_write_all(uxsock, ".\n", 2);
847 fd_gets(uxsock, buf, sizeof(buf));
848 if (!strncmp(buf, ".\n", 2)) break;
852 fd_write_all(uxsock, "popup\n", 6);
858 static gint lock_socket_remove(void)
862 if (lock_socket < 0) return -1;
864 if (lock_socket_tag > 0)
865 gdk_input_remove(lock_socket_tag);
866 fd_close(lock_socket);
867 filename = get_socket_name();
873 static GPtrArray *get_folder_item_list(gint sock)
877 GPtrArray *folders = NULL;
880 fd_gets(sock, buf, sizeof(buf));
881 if (!strncmp(buf, ".\n", 2)) break;
883 if (!folders) folders = g_ptr_array_new();
884 item = folder_find_item_from_identifier(buf);
886 g_ptr_array_add(folders, item);
888 g_warning("no such folder: %s\n", buf);
894 static void lock_socket_input_cb(gpointer data,
896 GdkInputCondition condition)
898 MainWindow *mainwin = (MainWindow *)data;
902 sock = fd_accept(source);
903 fd_gets(sock, buf, sizeof(buf));
905 if (!strncmp(buf, "popup", 5)) {
906 main_window_popup(mainwin);
907 } else if (!strncmp(buf, "receive_all", 11)) {
908 inc_all_account_mail(mainwin, FALSE,
909 prefs_common.newmail_notify_manu);
910 } else if (!strncmp(buf, "receive", 7)) {
911 inc_mail(mainwin, prefs_common.newmail_notify_manu);
912 } else if (!strncmp(buf, "compose_attach", 14)) {
916 mailto = g_strdup(buf + strlen("compose_attach") + 1);
917 files = g_ptr_array_new();
918 while (fd_gets(sock, buf, sizeof(buf)) > 0) {
919 if (buf[0] == '.' && buf[1] == '\n') break;
921 g_ptr_array_add(files, g_strdup(buf));
923 open_compose_new(mailto, files);
924 ptr_array_free_strings(files);
925 g_ptr_array_free(files, TRUE);
927 } else if (!strncmp(buf, "compose", 7)) {
928 open_compose_new(buf + strlen("compose") + 1, NULL);
929 } else if (!strncmp(buf, "send", 4)) {
931 } else if (!strncmp(buf, "online", 6)) {
932 main_window_toggle_work_offline(mainwin, FALSE);
933 } else if (!strncmp(buf, "offline", 7)) {
934 main_window_toggle_work_offline(mainwin, TRUE);
935 } else if (!strncmp(buf, "status-full", 11) ||
936 !strncmp(buf, "status", 6)) {
940 folders = get_folder_item_list(sock);
941 status = folder_get_status
942 (folders, !strncmp(buf, "status-full", 11));
943 fd_write_all(sock, status, strlen(status));
944 fd_write_all(sock, ".\n", 2);
946 if (folders) g_ptr_array_free(folders, TRUE);
952 static void open_compose_new(const gchar *address, GPtrArray *attach_files)
957 Xstrdup_a(addr, address, return);
961 compose_new(NULL, addr, attach_files);
964 static void send_queue(void)
968 for (list = folder_get_list(); list != NULL; list = list->next) {
969 Folder *folder = list->data;
972 gint res = procmsg_send_queue
973 (folder->queue, prefs_common.savemsg);
976 alertpanel_error(_("Some errors occurred while sending queued messages."));
978 folder_item_scan(folder->queue);
983 static void quit_signal_handler(int sig)
985 debug_print("Quitting on signal %d\n", sig);
987 g_timeout_add(0, clean_quit, NULL);
990 static void install_basic_sighandlers()
993 struct sigaction act;
998 sigaddset(&mask, SIGTERM);
1001 sigaddset(&mask, SIGINT);
1004 sigaddset(&mask, SIGHUP);
1007 act.sa_handler = quit_signal_handler;
1012 sigaction(SIGTERM, &act, 0);
1015 sigaction(SIGINT, &act, 0);
1018 sigaction(SIGHUP, &act, 0);
1021 sigprocmask(SIG_UNBLOCK, &mask, 0);