[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

SBCL as a background process

Mark Tarver

4/22/2015 11:25:00 PM

Is there any way of invoking SBCL (or for that matter CLisp) as a background process under Windows w.o. having the REPL appear in a Window?

Mark
13 Answers

Kaz Kylheku

4/22/2015 11:59:00 PM

0

On 2015-04-22, Mark Tarver <dr.mtarver@gmail.com> wrote:
> Is there any way of invoking SBCL (or for that matter CLisp) as a background
> process under Windows w.o. having the REPL appear in a Window?

Hi Mark,

Yes there is: the CreateProcess WIN32 API. In the startup information structure
there is wShowWindow member to control this.

I developed an application using Clozure Common Lisp. I can interact with it in
a console window during debugging.

In deployed mode, it runs in the background on the user's machine, without
any window, and is controlled by a monitor program that I wrote using
Visual C++. The notification program launches the Lisp executable using
CreateProcess, in a way that the console window doesn't show.

The monitor program creates an icon in the system notification area ("tray").
This icon can report changes in status, like if the program happens to die, or
not launch successfully. Using the notification icon, the user can open
a browser window to connect to the background process's HTTP port. The user
can also request the termination of the background process.

(Obviously, I developed this not just to get rid of the console window, but
for an overall good user experience with the resulting background app.)

Other solutions for getting rid of the console window.

* Some people claim that calling FreeConsole() immediately on startup in the
executable does the job. I don't have experience with this and I'm somewhat
skeptical; maybe the console window will "flash" briefly sometimes?

* Here is one way that, once upon a time, I tried with CLISP. It seemed to work.
Given a compiled and linked Windows executable (.exe file), you can still
change its "subsystem type". For instance, you can change a console app
to a windows app.

I can't remember what utility I used to do this (raw hex editor?) but after some
searching just now, I found the "exetype" utility, apparently courtesy of the
ActiveState Perl people:

http://docs.activestate.com/activeperl/5.8/bin/ex...

Normally, when people compile Visual C++ programs, there is a linker option
for this which chooses the "subsystem type". See if it works on your Lisp
executable.

Pascal J. Bourguignon

4/23/2015 12:39:00 AM

0

Mark Tarver <dr.mtarver@gmail.com> writes:

> Is there any way of invoking SBCL (or for that matter CLisp) as a
> background process under Windows w.o. having the REPL appear in a
> Window?

man clisp: use -c -x or lispfile arguments.


--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Madhu

4/23/2015 6:16:00 AM

0


* Kaz Kylheku <20150422163033.624@kylheku.com> :
Wrote on Wed, 22 Apr 2015 23:59:20 +0000 (UTC):

| On 2015-04-22, Mark Tarver <dr.mtarver@gmail.com> wrote:
|> Is there any way of invoking SBCL (or for that matter CLisp) as a background
|> process under Windows w.o. having the REPL appear in a Window?
|
| Yes there is: the CreateProcess WIN32 API. In the startup information
| structure there is wShowWindow member to control this.
|
| I developed an application using Clozure Common Lisp. I can interact
| with it in a console window during debugging.
|
| In deployed mode, it runs in the background on the user's machine,
| without any window, and is controlled by a monitor program that I
| wrote using Visual C++. The notification program launches the Lisp
| executable using CreateProcess, in a way that the console window
| doesn't show.

GNU Emacs ships with a file nt/runemacs.c to "start Emacs with its
console window hidden". This is a CreateProcess wrapper around
"emacs.exe". Perhaps there are general versions of this `exec' utility
to do the same for any executable that starts a console window.

If OTOH the OP wanted to use the Windows Services subsystem to run a
`backrgound' process---franz had `ntservice' and LW ships with
examples/delivery/ntservice/ to do this from lisp---then the console
window may not show up unless the service runs as a certain privileged
local user account, [I haven't run win7 since maybe 2010, so this
information "should be treated circumspectly"]

[snip]

---Madhu

Mark Tarver

4/23/2015 12:16:00 PM

0

On Thursday, April 23, 2015 at 12:59:24 AM UTC+1, Kaz Kylheku wrote:
> On 2015-04-22, Mark Tarver <dr.mtarver@gmail.com> wrote:
> > Is there any way of invoking SBCL (or for that matter CLisp) as a background
> > process under Windows w.o. having the REPL appear in a Window?
>
> Hi Mark,
>
> Yes there is: the CreateProcess WIN32 API. In the startup information structure
> there is wShowWindow member to control this.
>
> I developed an application using Clozure Common Lisp. I can interact with it in
> a console window during debugging.
>
> In deployed mode, it runs in the background on the user's machine, without
> any window, and is controlled by a monitor program that I wrote using
> Visual C++. The notification program launches the Lisp executable using
> CreateProcess, in a way that the console window doesn't show.
>
> The monitor program creates an icon in the system notification area ("tray").
> This icon can report changes in status, like if the program happens to die, or
> not launch successfully. Using the notification icon, the user can open
> a browser window to connect to the background process's HTTP port. The user
> can also request the termination of the background process.
>
> (Obviously, I developed this not just to get rid of the console window, but
> for an overall good user experience with the resulting background app.)
>
> Other solutions for getting rid of the console window.
>
> * Some people claim that calling FreeConsole() immediately on startup in the
> executable does the job. I don't have experience with this and I'm somewhat
> skeptical; maybe the console window will "flash" briefly sometimes?
>
> * Here is one way that, once upon a time, I tried with CLISP. It seemed to work.
> Given a compiled and linked Windows executable (.exe file), you can still
> change its "subsystem type". For instance, you can change a console app
> to a windows app.
>
> I can't remember what utility I used to do this (raw hex editor?) but after some
> searching just now, I found the "exetype" utility, apparently courtesy of the
> ActiveState Perl people:
>
> http://docs.activestate.com/activeperl/5.8/bin/ex...
>
> Normally, when people compile Visual C++ programs, there is a linker option
> for this which chooses the "subsystem type". See if it works on your Lisp
> executable.

Thanks for that; there is a discussion on the Shen group about using Shen to run outside the REPL which I have not yet done. CL is still my platform of choice for my work (despite having now umpteen implementations in different languages).

Mark

Mark Tarver

4/24/2015 11:16:00 AM

0

On Thursday, April 23, 2015 at 1:47:44 AM UTC+1, informatimago wrote:
> Mark Tarver <dr.mtarver@gmail.com> writes:
>
> > Is there any way of invoking SBCL (or for that matter CLisp) as a
> > background process under Windows w.o. having the REPL appear in a
> > Window?
>
> man clisp: use -c -x or lispfile arguments.
>
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

I tried

clisp.exe -M Shen.mem -x "(print 'hi)"

and it indeed printed hi - but the REPL popped up while doing and then disappeared.

I then tried

clisp.exe -M Shen.mem lisp-file "foo.shen"

which did nothing - just a normal REPL and the file was not loaded.

I'm reading http://man.cx/cl...

Mark

Mark Tarver

4/24/2015 11:22:00 AM

0

On Thursday, April 23, 2015 at 12:59:24 AM UTC+1, Kaz Kylheku wrote:
> On 2015-04-22, Mark Tarver <dr.mtarver@gmail.com> wrote:
> > Is there any way of invoking SBCL (or for that matter CLisp) as a background
> > process under Windows w.o. having the REPL appear in a Window?
>
> Hi Mark,
>
> Yes there is: the CreateProcess WIN32 API. In the startup information structure
> there is wShowWindow member to control this.
>
> I developed an application using Clozure Common Lisp. I can interact with it in
> a console window during debugging.
>
> In deployed mode, it runs in the background on the user's machine, without
> any window, and is controlled by a monitor program that I wrote using
> Visual C++. The notification program launches the Lisp executable using
> CreateProcess, in a way that the console window doesn't show.
>
> The monitor program creates an icon in the system notification area ("tray").
> This icon can report changes in status, like if the program happens to die, or
> not launch successfully. Using the notification icon, the user can open
> a browser window to connect to the background process's HTTP port. The user
> can also request the termination of the background process.
>
> (Obviously, I developed this not just to get rid of the console window, but
> for an overall good user experience with the resulting background app.)
>
> Other solutions for getting rid of the console window.
>
> * Some people claim that calling FreeConsole() immediately on startup in the
> executable does the job. I don't have experience with this and I'm somewhat
> skeptical; maybe the console window will "flash" briefly sometimes?
>
> * Here is one way that, once upon a time, I tried with CLISP. It seemed to work.
> Given a compiled and linked Windows executable (.exe file), you can still
> change its "subsystem type". For instance, you can change a console app
> to a windows app.
>
> I can't remember what utility I used to do this (raw hex editor?) but after some
> searching just now, I found the "exetype" utility, apparently courtesy of the
> ActiveState Perl people:
>
> http://docs.activestate.com/activeperl/5.8/bin/ex...
>
> Normally, when people compile Visual C++ programs, there is a linker option
> for this which chooses the "subsystem type". See if it works on your Lisp
> executable.

I'm looking at the docs I can find; I don't like Linux much for general usage but it is good for this stuff. Is there any way to do this w.o. hacking Perl/C++? Or is there any good page for running Windows programs in the background? Or else have SBCL people written on this?

Mark

Mark

Kaz Kylheku

4/24/2015 3:02:00 PM

0

On 2015-04-24, Mark Tarver <dr.mtarver@gmail.com> wrote:
> I'm looking at the docs I can find; I don't like Linux much for general
> usage but it is good for this stuff. Is there any way to do this w.o.
> hacking Perl/C++?

If you want to generate a Lisp image which starts as an executable without a
console window, the image-generating function in the given Lisp implementation
must have this as some kind of option.

I don't see one in CLISP's EXT:SAVEIMAGE; there isn't anything of the
sort as a :subsystem :windows keyword argument. (There obviously could be;
CLISP's image-saving function could incorporate the same logic as Activestate's
exetype utility to tweak the resulting executable.)

Speaking of which that exetype utility on Activestate's website doesn't appear
to have anything to do with Perl.

You could rewrite the equivalent of the exetype utility in Lisp, then apply it
to your executable as a post-processing step in a purely Lispy build process.

Pascal J. Bourguignon

4/24/2015 4:16:00 PM

0

Mark Tarver <dr.mtarver@gmail.com> writes:

> On Thursday, April 23, 2015 at 1:47:44 AM UTC+1, informatimago wrote:
>> Mark Tarver <dr.mtarver@gmail.com> writes:
>>
>> > Is there any way of invoking SBCL (or for that matter CLisp) as a
>> > background process under Windows w.o. having the REPL appear in a
>> > Window?
>>
>> man clisp: use -c -x or lispfile arguments.
>>
>>
>> --
>> __Pascal Bourguignon__ http://www.informat...
>> "The factory of the future will have only two employees, a man and a
>> dog. The man will be there to feed the dog. The dog will be there to
>> keep the man from touching the equipment." -- Carl Bass CEO Autodesk
>
> I tried
>
> clisp.exe -M Shen.mem -x "(print 'hi)"
>
> and it indeed printed hi - but the REPL popped up while doing and then
> disappeared.

REPL don't "pop up". They Read, Evaluate, Print and Loop.

If you don't get a read, an evaluate, a print or a loop, you don't get a
REPL.

And even less when you don't get either.

$ clisp -ansi -norc -q -x '(progn (write-line "Hello") (values))'
Hello

$


> I then tried
>
> clisp.exe -M Shen.mem lisp-file "foo.shen"
>
> which did nothing - just a normal REPL and the file was not loaded.

If lisp-file is not a lisp-file then it will signal an error.

$ echo '(write-line "hello from lisp-file")' > lisp-file
$ clisp -ansi -norc -q lisp-file
hello from lisp-file
$


> I'm reading http://man.cx/cl...

Reading is good. Understanding is better.


--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Pascal J. Bourguignon

4/24/2015 4:43:00 PM

0

Steve Graham <jsgrahamus@yahoo.com> writes:

>>
>> Reading is good. Understanding is better.
>>
>>
> On Windows 7x64:
> C:\Users\Steve>clisp -ansi -norc -q -x '(progn (write-line "Hello")
> (values))'
> GNU CLISP: -x with lisp-file is invalid: '(write-line'
> GNU CLISP: use '-h' for help
>
> C:\Users\Steve>

Right, so?

Did you use '-h' for help as GNU CLISP told you?

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

jsgraham

4/24/2015 4:45:00 PM

0

Pascal J. Bourguignon wrote:
> Mark Tarver <dr.mtarver@gmail.com> writes:
>
>> On Thursday, April 23, 2015 at 1:47:44 AM UTC+1, informatimago wrote:
>>> Mark Tarver <dr.mtarver@gmail.com> writes:
>>>
>>>> Is there any way of invoking SBCL (or for that matter CLisp) as a
>>>> background process under Windows w.o. having the REPL appear in a
>>>> Window?
>>>
>>> man clisp: use -c -x or lispfile arguments.
>>>
>>>
>>> --
>>> __Pascal Bourguignon__ http://www.informat...
>>> "The factory of the future will have only two employees, a man and a
>>> dog. The man will be there to feed the dog. The dog will be there to
>>> keep the man from touching the equipment." -- Carl Bass CEO Autodesk
>>
>> I tried
>>
>> clisp.exe -M Shen.mem -x "(print 'hi)"
>>
>> and it indeed printed hi - but the REPL popped up while doing and then
>> disappeared.
>
> REPL don't "pop up". They Read, Evaluate, Print and Loop.
>
> If you don't get a read, an evaluate, a print or a loop, you don't get a
> REPL.
>
> And even less when you don't get either.
>
> $ clisp -ansi -norc -q -x '(progn (write-line "Hello") (values))'
> Hello
>
> $
>
>
>> I then tried
>>
>> clisp.exe -M Shen.mem lisp-file "foo.shen"
>>
>> which did nothing - just a normal REPL and the file was not loaded.
>
> If lisp-file is not a lisp-file then it will signal an error.
>
> $ echo '(write-line "hello from lisp-file")' > lisp-file
> $ clisp -ansi -norc -q lisp-file
> hello from lisp-file
> $
>
>
>> I'm reading http://man.cx/cl...
>
> Reading is good. Understanding is better.
>
>
On Windows 7x64:
C:\Users\Steve>clisp -ansi -norc -q -x '(progn (write-line "Hello")
(values))'
GNU CLISP: -x with lisp-file is invalid: '(write-line'
GNU CLISP: use '-h' for help

C:\Users\Steve>