Thread overview
Daemons?
Aug 15, 2007
Daniel Swe
Aug 15, 2007
Regan Heath
Aug 15, 2007
Deewiant
Aug 15, 2007
Daniel Swe
Aug 15, 2007
Deewiant
Aug 15, 2007
Regan Heath
Aug 15, 2007
BCS
Aug 16, 2007
Daniel Swe
August 15, 2007
I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.

    //With regards Daniel Swe.


August 15, 2007
Daniel Swe wrote:
> I'm trying to make a GUI that can display both opengl windows and/or
> terminal windows (using ncurses). So one could start the program
> using a terminal (using ./test -console for example) at work. But
> later when I get home I would like a opengl window so I write ./test
> -opengl , and the same instance of the program that was used for the
> console would pop up with all the bells and whistles for opengl. The
> problem is that I don't really know how to do it. Should I make a
> daemon that guis connect to? Is there any way to find the pid and
> communicate with the instance using tango? Or is there another more
> clever way? I'm currently using gdc and Tango in Ubuntu.

Named pipes perhaps:
http://open.itworld.com/nl/lnx_tip/08232002/

Regan
August 15, 2007
Daniel Swe wrote:
> I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.
> 

What's the problem? Just abstract out the user interface to a separate module (or package, if it grows large enough) and instantiate a different type of object depending on the command line. Or call a different set of functions, or have a global enum which chooses between UIs, but I think the OO approach is cleanest here.

-- 
Remove ".doesnotlike.spam" from the mail address.
August 15, 2007
I want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance.

Deewiant Wrote:

> Daniel Swe wrote:
> > I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.
> > 
> 
> What's the problem? Just abstract out the user interface to a separate module (or package, if it grows large enough) and instantiate a different type of object depending on the command line. Or call a different set of functions, or have a global enum which chooses between UIs, but I think the OO approach is cleanest here.
> 
> -- 
> Remove ".doesnotlike.spam" from the mail address.

August 15, 2007
Daniel Swe wrote:
> I want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance.

I'd probably use sockets, as they're practically universally supported and don't require platform-specific code. If you're willing to go POSIX-only you could also try named pipes, as Regan suggested.

See also http://en.wikipedia.org/wiki/Inter-process_communication

-- 
Remove ".doesnotlike.spam" from the mail address.
August 15, 2007
Deewiant wrote:
> Daniel Swe wrote:
>> I want a single instance of the program. So that when I write ./test -console
>> it doesnt really start a new instance of the program but instead connects to
>> the older instance.
> 
> I'd probably use sockets, as they're practically universally supported and don't
> require platform-specific code. If you're willing to go POSIX-only you could
> also try named pipes, as Regan suggested.
> 
> See also http://en.wikipedia.org/wiki/Inter-process_communication

Yeah, I was just about to suggest sockets.

If you use named pipes you will have code for windows and code for unix, or you could just ignore windows for your specific case.

Once you're done you could polish it up and suggest it gets included in Tango.

If you want to do that then take a look at tango.sys.Pipe because a NamedPipe will be almost identical to that.

The code to read/write the pipe can be found in tango.sys.Process.

Regan

August 15, 2007
Deewiant wrote:
> Daniel Swe wrote:
> 
>>I want a single instance of the program. So that when I write ./test -console
>>it doesnt really start a new instance of the program but instead connects to
>>the older instance.
> 
> 
> I'd probably use sockets, as they're practically universally supported and don't
> require platform-specific code. If you're willing to go POSIX-only you could
> also try named pipes, as Regan suggested.
> 
> See also http://en.wikipedia.org/wiki/Inter-process_communication
> 

sockets would have the nice side effect that you could run the CLI/GUI on a different system.
August 16, 2007
Thanks, all of you! I wlll be using sockets. I don't look forward to the message pump though ( needs alot of if's or switches).


Daniel Swe Wrote:

> I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.
> 
>     //With regards Daniel Swe.
> 
>