aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-14 08:26:02 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-14 08:26:02 +0000
commit57cf5f7e26b171e680ba27958a414703a51768e4 (patch)
treeaef2d62f4e390432cb52db3ea1a2b3a2056df624
parent8db157d7a1a1fdc49dda5de5eff7bb29766a6009 (diff)
win32: prohibit duplicate exec using CreateMutex().
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@648 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog4
-rw-r--r--src/main.c22
2 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a1644a1..612a05ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2005-10-14
+ * src/main.c: win32: prohibit duplicate exec using CreateMutex().
+
+2005-10-14
+
* libsylph/procmime.c
src/compose.c: made some warnings just debug messages.
diff --git a/src/main.c b/src/main.c
index 0b3582ca..79da0a7e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -87,6 +87,10 @@
# include "ssl.h"
#endif
+#ifdef G_OS_WIN32
+# include <windows.h>
+#endif
+
#include "version.h"
gchar *prog_version;
@@ -163,11 +167,11 @@ int main(int argc, char *argv[])
app_init();
parse_cmd_opt(argc, argv);
-#ifdef G_OS_UNIX
/* check and create unix domain socket for remote operation */
lock_socket = prohibit_duplicate_launch();
if (lock_socket < 0) return 0;
+#ifdef G_OS_UNIX
if (cmd.status || cmd.status_full) {
puts("0 Sylpheed not running.");
lock_socket_remove();
@@ -742,6 +746,21 @@ static gchar *get_socket_name(void)
static gint prohibit_duplicate_launch(void)
{
+#ifdef G_OS_WIN32
+ HANDLE hmutex;
+
+ hmutex = CreateMutexA(NULL, FALSE, "Sylpheed");
+ if (!hmutex) {
+ g_warning("cannot create Mutex\n");
+ return -1;
+ }
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ debug_print(_("another Sylpheed is already running.\n"));
+ return -1;
+ }
+
+ return 0;
+#else
gint uxsock;
gchar *path;
@@ -821,6 +840,7 @@ static gint prohibit_duplicate_launch(void)
fd_close(uxsock);
return -1;
+#endif
}
static gint lock_socket_remove(void)