Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-09

Data exchange between programs

8 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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?

Matt Emson
to Carsten Bager
Show quoted text 5 lines
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

Dominique Leducq
to Matt Emson
Matt Emson wrote 8 lines
> 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.

Show quoted text 8 lines
HTH, M _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Michael Van Canneyt
to Carsten Bager: I have 2 FPC programs running on a Linux machine, is there an easy way to exchange a few…
Carsten Bager wrote 6 lines
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.

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

Leonardo M. Ram�
to Michael Van Canneyt: I think you'd better use shared memory or pipes or so. If the communication is one-way,…

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 wrote 19 lines
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 - 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

Felipe Monteiro de Carvalho
to Carsten Bager: I have 2 FPC programs running on a Linux machine, is there an easy way to exchange a few…
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

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
Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 16 lines
On 9/6/06, 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 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.