Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HG changeset patch
- # User Jerome LAFORGE
- # Date 1315058971 -7200
- # Node ID 99b48eeeef711990c08473a71541e524ddf7ca3c
- # Parent 87da4634b76fb779e054d579989f496c8e78db70
- Ensure unique instance when check.if.already.open is set.
- Bug #3363754.
- diff -r 87da4634b76f -r 99b48eeeef71 gtk/SciTEGTK.cxx
- --- a/gtk/SciTEGTK.cxx Sun Aug 21 10:31:44 2011 +0200
- +++ b/gtk/SciTEGTK.cxx Sat Sep 03 16:09:31 2011 +0200
- @@ -106,6 +106,7 @@
- }
- const char appName[] = "SciTE";
- +static char uniqueInstance[MAX_PATH];
- static GtkWidget *PWidget(GUI::Window &w) {
- return reinterpret_cast<GtkWidget *>(w.GetID());
- @@ -4351,6 +4352,15 @@
- char *pipeFileName = NULL;
- const char *filename;
- + sprintf(uniqueInstance,"%s/SciTE.ensure.unique.instance.for.%s", g_get_tmp_dir(), getenv("USER"));
- + int fd = -2;
- + do {
- + if (fd == -1)
- + usleep(50000); // Currently, another process of SciTE is launching. We are waiting for end of its initialisation.
- + fd = open(uniqueInstance, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- + } while (fd == -1 && errno == EEXIST);
- + if (fd != -1)
- + close(fd);
- // Find a working pipe in our temporary directory
- while ((filename = g_dir_read_name(dir))) {
- if (g_pattern_match_string(pattern, filename)) {
- @@ -4386,6 +4396,7 @@
- // We need to call this since we're not displaying a window
- gdk_notify_startup_complete();
- g_free(pipeFileName);
- + unlink(uniqueInstance);
- return true;
- }
- @@ -4429,6 +4440,8 @@
- }
- CreateUI();
- + if ((props.Get("ipc.director.name").size() == 0) && props.GetInt ("check.if.already.open"))
- + unlink(uniqueInstance);
- // Process remaining switches and files
- ProcessCommandLine(args, 1);
Add Comment
Please, Sign In to add comment