Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Command shell still required?  (Read 10816 times)
Tim B.
Posts: 67


« on: December 02, 2008, 03:34:56 pm »

I notice when programs are launched from a Start Menu program they still start in a command shell (cmd.exe).  Is this still necessary in Genero?  The Start Menu itself (in our case) is a direct child of the GASD process and doesn't run inside a command shell, which suggests one is not needed.

The issue is that these cmd processes clog up the system and use up lots of resource, limiting its capacity.
Leo S.
Four Js
Posts: 126


« Reply #1 on: December 02, 2008, 05:19:56 pm »

Hi Tim,
the Start Menu file contains for each StartMenuCommand entry the 'exec' attribute describing the actual command line.
The command line can contain arguments and therefore fglrun must call something parsing the command line in a known way.
Internally fglrun calls the same routine which is also serving the "RUN" statement.
What you can do on Windows  according to the doc of "RUN" is setting COMSPEC to something else than cmd.exe
Suppose you are willing to write a small Windows C-program mycmd.exe and
suppose you set "SET COMSPEC=mycmd.exe" fglrun translates a
RUN "fglrun foo"  or the exec string exec="fglrun foo" from the StartMenuCommand to
call
 CreateProcess(..,"mycmd.exe /c fglrun foo" ,...);
mycmd.exe could then eat the /c and pass the "fglrun foo" to CreateProcess() which should be more lightweight than cmd.exe.
In any case you will need an additional executable to spawn your children, you can't surround that.
HTH and Kind Regards,Leo
Leo S.
Four Js
Posts: 126


« Reply #2 on: December 02, 2008, 06:22:33 pm »

Just a small adjustment, fglrun does the COMSPEC thing on Windows *only* for RUN xxx WITHOUT WAITING(and for the StartMenu stuff), for a normal RUN (with wait) it uses the "system()" C-library call...
Kind Regards, Leo
Tim B.
Posts: 67


« Reply #3 on: December 05, 2008, 10:51:18 am »

It's not really the amount of memory, because cmd.exe uses very little anyway.  It's more the number of processes that are running.  I have a BDS program which kills these off to free up resources, since after they have launched they seem to serve no purpose.  I'll continue to use this in Genero.

I don't entirely understand the issue about why this is necessary (my lack of knowledge in this area).  A command shell isn't required on Linux/Unix.  Maybe it's just a Windowz thing :)
Leo S.
Four Js
Posts: 126


« Reply #4 on: December 05, 2008, 02:25:20 pm »

There is a shell invoked on Linux if you use RUN WITHOUT WAITING:
rww.4gl
MAIN
  RUN "fglrun huhu" WITHOUT WAITING
  SLEEP 10000
END MAIN

huhu.4gl
MAIN
  SLEEP 10000
END MAIN

leo@fuji2:~/tmp$ fglrun rww &
[1] 15506
leo@fuji2:~/tmp$ ps axf | grep fglrun
15506 pts/2    S      0:00  |           \_ /home/leo/w/fgl2.11/opt/fgl/lib/fglrun-bin rww
15515 pts/2    S+     0:00  |           \_ grep fglrun
15512 pts/2    S      0:00 sh -c fglrun huhu
15513 pts/2    S      0:00  \_ /home/leo/w/fgl2.11/opt/fgl/lib/fglrun-bin huhu

The shell is needed if you have redirections/multiple commands in your command, for example
RUN "fglrun foo >bar 2>err" WITHOUT WAITING
or
RUN "fglrun spong | someothercommand" WITHOUT WAITING
or
RUN "set FGLSERVER=ben:0&&fglrun theben" WITHOUT WAITING

Killing the cmd.exe on windows is another solution....:-)
I would not really recommend it  however, because killing processes on windows is not that program friendly supported as on UNIX .
But this is up to you.
Kind Regards, Leo

Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines