Data exchange between programs

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Data exchange between programs

Carsten Bager
I have 2 FPC programs running on a Linux machine, is there an easy
way to exchange a few data between these programs (I do not want to
use disk operations). I was thinking of using environment variables,
but I cannot find a way to change environment variables from a
program.
Does anybody have a hint?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Matt Emson
>I have 2 FPC programs running on a Linux machine, is there an easy
> way to exchange a few data between these programs (I do not want to
> use disk operations). I was thinking of using environment variables,
> but I cannot find a way to change environment variables from a
> program.

MMap? Unix domain sockets? Or do these count as file operations?

Isn't there a GetEnv and SetEnv procedure/function somewhere in the LINUX
RTL? Libc or somewhere like that?

HTH,

M


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Dominique Leducq-2
Matt Emson a écrit :
>> I have 2 FPC programs running on a Linux machine, is there an easy
>> way to exchange a few data between these programs (I do not want to
>> use disk operations). I was thinking of using environment variables,
>> but I cannot find a way to change environment variables from a
>> program.
>
> MMap? Unix domain sockets? Or do these count as file operations?
>

pipes,
IPC SysV message queues or shared memory (depends on what portability
you need; needs libc linking).
Things are simpler if the processes that need to communicate descend
from a common ancestor which can setup the communication, allowing
unnamed pipes, or private IPC SysV resources.

> Isn't there a GetEnv and SetEnv procedure/function somewhere in the
> LINUX RTL? Libc or somewhere like that?
>

If you set an environment variable in a process, only the descendent
processes will inherit and see it, and only the value it has when the
fork occured, so that's usually not an option.

> HTH,
>
> M
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Michael Van Canneyt
In reply to this post by Carsten Bager


On Wed, 6 Sep 2006, Carsten Bager wrote:

> I have 2 FPC programs running on a Linux machine, is there an easy
> way to exchange a few data between these programs (I do not want to
> use disk operations). I was thinking of using environment variables,
> but I cannot find a way to change environment variables from a
> program.
> Does anybody have a hint?

I think you'd better use shared memory or pipes or so.
If the communication is one-way, have a look at the simpleipc units.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Carsten Bager
In reply to this post by Carsten Bager
> I think you'd better use shared memory or pipes or so.
> If the communication is one-way, have a look at the simpleipc units.
>
> Michael.

I have used the ipc functions, and they did the trick

Thanks

Carsten

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Leonardo M. Ramé
In reply to this post by Michael Van Canneyt
Or encapsulate your variables into an object and pass it to the DLL.

Check out my blog at http://leonardorame.blogspot.com to see how pass objects to Dlls.

--- Michael Van Canneyt <[hidden email]> wrote:

>
>
> On Wed, 6 Sep 2006, Carsten Bager wrote:
>
> > I have 2 FPC programs running on a Linux machine, is there an easy
> > way to exchange a few data between these programs (I do not want to
> > use disk operations). I was thinking of using environment variables,
> > but I cannot find a way to change environment variables from a
> > program.
> > Does anybody have a hint?
>
> I think you'd better use shared memory or pipes or so.
> If the communication is one-way, have a look at the simpleipc units.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Leonardo M. Ramé
http://leonardorame.blogspot.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Felipe Monteiro de Carvalho
In reply to this post by Carsten Bager
On 9/6/06, Carsten Bager <[hidden email]> wrote:
> I have 2 FPC programs running on a Linux machine, is there an easy
> way to exchange a few data between these programs

A very good alternative is dbus: http://www.freedesktop.org/wiki/Software/dbus

It´s the standard GNU project for data exchange between programs. It´s
also cross-platform.

I translated dbus headers to Pascal, and I will very soon (perhaps
today?) make a release of them.

I will also translate this tutorial to pascal:

http://dbus.freedesktop.org/doc/dbus/libdbus-tutorial.html
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Data exchange between programs

Michael Van Canneyt


On Wed, 6 Sep 2006, Felipe Monteiro de Carvalho wrote:

> On 9/6/06, Carsten Bager <[hidden email]> wrote:
>> I have 2 FPC programs running on a Linux machine, is there an easy
>> way to exchange a few data between these programs
>
> A very good alternative is dbus:
> http://www.freedesktop.org/wiki/Software/dbus
>
> It´s the standard GNU project for data exchange between programs. It´s
> also cross-platform.
>
> I translated dbus headers to Pascal, and I will very soon (perhaps
> today?) make a release of them.
>
> I will also translate this tutorial to pascal:
>
> http://dbus.freedesktop.org/doc/dbus/libdbus-tutorial.html
Using dbus makes your code dependent on the C library, and
this is not always desirable. For simple things, it's better
not to have any external dependencies.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal