[Gambas-user] Avoiding multiple instances

Stefano Palmeri rospolosco at ...152...
Fri Feb 1 14:37:19 CET 2008


Alle 13:42, venerdì 1 febbraio 2008, Stefano Palmeri ha scritto:
> Alle 13:31, venerdì 1 febbraio 2008, Benoit Minisini ha scritto:
> > On vendredi 1 février 2008, Stefano Palmeri wrote:
> > > Alle 18:38, giovedì 31 gennaio 2008, Epíleg ha scritto:
> > > > En/na Stefano Palmeri ha escrit:
> > > > > Alle 16:45, giovedì 31 gennaio 2008, Stefano Palmeri ha scritto:
> > > > >> I use this simple code:
> > > > >>
> > > > >> PUBLIC SUB Main()
> > > > >>
> > > > >>   DIM sShellOutput AS String
> > > > >>
> > > > >>   SHELL "ps aux | grep " & Application.Name & ".gambas" & " | grep
> > > > >> -v grep" TO sShellOutput
> > > > >>
> > > > >>   IF sShellOutput THEN QUIT
> > > > >>
> > > > >> END
> > > > >
> > > > > or better:
> > > > >
> > > > > PUBLIC SUB Main()
> > > > >
> > > > >   DIM sShellOutput AS String
> > > > >
> > > > >   SHELL "ps aux | grep " & Application.Name & ".gambas" &
> > > > >         " | grep -wv grep | wc -l" TO sShellOutput
> > > > >
> > > > >   IF Val(sShellOutput) > 1 THEN QUIT
> > > > >
> > > > > END
> > > >
> > > > Very good solution. Thanks a lot!
> > > >
> > > > Epíleg.
> > >
> > > I found out that using Application.Args[0] is better,
> > > because we don't have to care if the user renames the binary.
> > >
> > > PUBLIC SUB Main()
> > >
> > >    DIM sShellOutput AS String
> > >
> > >      SHELL "ps aux | grep  -w " & Application.Args[0]&
> > >          " | grep -wv grep | wc -l" TO sShellOutput
> > >
> > >      IF Val(sShellOutput) > 1 THEN QUIT
> > >
> > > END
> > >
> > > Stefano
> >
> > I have a 'pgrep' command on my system for finding a process from its name
> > (and many other things).
> >
> > Regards,
>
> Yes, but it seems that pgrep (as pidof) can't manage a Gambas binary.
> That's why I use "ps aux | grep blahblah".
>
> Stefano

Errata corrige: "pgrep -f gambas_ binary_name" works. Very useful info. Thanks 
Benoit for suggestion.

Stefano

>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list