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?
Mailing lists / fpc-pascal / 2006-09
Data exchange between programs
8 messages · 6 people ·
- CCarsten Bager 2
- MMichael Van Canneyt 2
- DDominique Leducq 1
- FFelipe Monteiro de Carvalho 1
- LLeonardo M. Ram� 1
- MMatt Emson 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Show quoted text 5 lines
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
Matt Emson wrote 8 lines
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
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 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 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
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
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
I have 2 FPC programs running on a Linux machine, is there an easy way to exchange a few…
Carsten Bager wroteI 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 wrote 16 lines
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.
