[racket] multiple instances of compiled for distribution software

13 views
Skip to first unread message

Zelah Hutchinson

unread,
May 19, 2013, 8:10:43 PM5/19/13
to us...@racket-lang.org
I am curious as to whether it would be possible to run multiple instances of a compiled Racket program. If so, then how may I do this? When I try to run the program twice by double clicking in Mac OS, I still only get one running process. This seems like a very serious limitation. Is there a way around this?
3D Marine Aquarium Screensaver Preview
Free 3D Marine Aquarium Screensaver
Watch dolphins, sharks & orcas on your desktop! Check it out at www.inbox.com/marineaquarium

Matthew Flatt

unread,
May 20, 2013, 8:47:55 AM5/20/13
to Zelah Hutchinson, us...@racket-lang.org
At Sun, 19 May 2013 16:10:43 -0800, Zelah Hutchinson wrote:
> I am curious as to whether it would be possible to run multiple
> instances of a compiled Racket program. If so, then how may I do
> this? When I try to run the program twice by double clicking in Mac
> OS, I still only get one running process. This seems like a very
> serious limitation. Is there a way around this?

Racket GUI programs on Mac OS X behave like other Mac OS X GUI
programs, which means that double-clicking the icon moves a previously
started instance to the front --- but also that you can start multiple
instances by using the command line.

Here's one way:

http://reviews.cnet.com/8301-13727_7-57564478-263/how-to-open-multiple-instances-of-an-application-in-os-x/


I don't know why there isn't a GUI way to do that in Mac OS X, but
below is a little Racket program that you can turn into an application
and use to launch a new instance of any Mac application.

----------------------------------------

#lang racket/gui

(define f (get-file
"Choose an Application"
#f
#f
#f
#f
'(packages)
'(("*.app" "Application"))))

(system* "/usr/bin/open"
"-n"
"-a"
f)

____________________
Racket Users list:
http://lists.racket-lang.org/users

Hendrik Boom

unread,
May 20, 2013, 11:21:38 AM5/20/13
to us...@racket-lang.org
On Sun, May 19, 2013 at 04:10:43PM -0800, Zelah Hutchinson wrote:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD><META http-equiv=Content-Type content="text/html; charset=utf-8"><META content="INBOX.COM" name=GENERATOR></HEAD>
> <BODY>
> I am curious as to whether it would be possible to run multiple instances of a compiled Racket program. If so, then how may I do this? When I try to run the program twice by double clicking in Mac OS, I still only get one running process. This seems like a very serious limitation. Is there a way around this?<hr size="1px" noshade style="clear:both;margin-top:10px;height:1px;">
> <div style="font:12px Verdana,sans-serif;color:Black;background:white;padding:3px;line-height:1.3em">
> <a href="http://www.inbox.com/marineaquarium"><img src="http://my.inbox.com/img/ftrs/marine.jpg" width="104" hight="90" alt="3D Marine Aquarium Screensaver Preview" align="left" border="0" style="margin-right:15px" /></a>
> <br><strong><font color="2086c3">Free 3D Marine Aquarium Screensaver</font></strong><br>
> <nobr>Watch dolphins, sharks &amp; orcas on your desktop!</nobr> <nobr>Check it out at <a href="http://www.inbox.com/marineaquarium">www.inbox.com/marineaquarium</a></nobr></div>
> </BODY>
> </HTML>
>
>
Mentioned this to my son, who had an intel mac laptop on his lap, and he
said, Command-N.

And showed me a number of programs for which it worked, by typing
command-N when the program's first window had focus.

Including DrRacket.

-- hendrik

Justin R. Slepak

unread,
May 20, 2013, 12:04:14 PM5/20/13
to us...@racket-lang.org
Cmd-N typically just opens a new window in the current instance. Use cmd-tab or look in the Dock, and you'll see you still only have one instance of your program running. Explicitly invoking the executable inside the .app bundle will produce a separate instance -- you can see on cmd-tab that you have two instances running.

---
Justin Slepak
PhD student, Computer Science dept.

Zelah Hutchinson

unread,
May 20, 2013, 8:48:50 PM5/20/13
to us...@racket-lang.org
So I think I have a handle on how to run multiple instances of a compiled program under Mac OS. I should be able to catch the command-n keyboard input in my compiled application. But I run into a similar problem when I work in Windows OS. I compile my source code for distribution. When I double click the application icon for a second time, I still only get one instance of the program. This seems like unusual behavior under Windows. What should I do here to obtain multiple instances?
Try IM ToolPack Try FREE IM ToolPack at www.imtoolpack.com
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace, LinkedIn® – FAST!

Zelah Hutchinson

unread,
May 21, 2013, 4:38:45 PM5/21/13
to us...@racket-lang.org
So I think I have a handle on how to run multiple instances of a compiled program under Mac OS. I should be able to catch the command-n keyboard input in my compiled application. But I run into a similar problem when I work in Windows OS. I compile my source code for distribution. When I double click the application icon for a second time, I still only get one instance of the program. I would like to get a second instance by double clicking the application icon. What should I do?
Smileys Preview
Get Free Smileys for Your IM & Email - Learn more at www.crawler.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk and most webmails

Zelah Hutchinson

unread,
May 21, 2013, 5:05:50 PM5/21/13
to us...@racket-lang.org
So I think I have a handle on how to run multiple instances of a compiled program under Mac OS. I should be able to catch the command-n keyboard input in my compiled application. But I run into a similar problem when I work in Windows OS. I compile my source code for distribution. When I double click the application icon for a second time, I still only get one instance of the program. I would like to get a second instance by double clicking the application icon. What should I do?

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at http://www.inbox.com/earth

Matthew Flatt

unread,
May 22, 2013, 10:07:17 AM5/22/13
to Zelah Hutchinson, us...@racket-lang.org
At Mon, 20 May 2013 16:48:50 -0800, Zelah Hutchinson wrote:
> So I think I have a handle on how to run multiple instances of a
> compiled program under Mac OS. I should be able to catch the
> command-n keyboard input in my compiled application. But I run into a
> similar problem when I work in Windows OS. I compile my source code
> for distribution. When I double click the application icon for a
> second time, I still only get one instance of the program. This seems
> like unusual behavior under Windows. What should I do here to obtain
> multiple instances?

It does seem like it has become unusual behavior under Windows. I think
it was common back when we made that choice, but it's also possible
that I was confused back then.

Single-instance mode can be disabled in an executable, but I see that
the configuration is currently only available at the level of the
`create-embedding-executable' function. I'll add a more accessible
point of configuration.

Meanwhile, you could manually edit the binary to change its mode. The
string "yes, please check for another" is embedded in the generated
".exe" file. If you change that leading "y" to "n" (I know that sounds
crazy), then single-instance mode is disabled.

Below is a Racket program that will change an executable for you.

----------------------------------------

#lang racket/gui

(define exe-file (get-file))

(define-values (i o)
(open-input-output-file exe-file #:exists 'update))

(define m (regexp-match-positions
#rx#"yes, please check for another"
i))
(unless m
(error "not a single-instance Racket-generate GUI executable"))

(close-input-port i)

(file-position o (caar m))
(write-byte (char->integer #\n) o)

(close-output-port o)
Reply all
Reply to author
Forward
0 new messages