Monday, May 24, 2010

How to use IPC here (C++)?

Lets say X is a shell command that will get you into X-shell upon execution. There's a command, a module, Y that can be run only in X-shell. How can I run Y from a C++ code? I need to somehow tell my app that the environment it'll be dealing with will be X-shell and not the Linux shell. I haven't dealt with a case like that before and don't know how to incorporate IPC here. Would I take X-shell as the parent process and the spawned child as module Y? Not sure... I should point out that it's not possible to do something like "X-shell -c Y"; first X-shell has to be executed. Once in the X-shell environment, now Y can be called.





A word of wisdom is appreciated.

How to use IPC here (C++)?
Good question. If I remember correctly, can't you use one of the flavors of execve(...) to execute a script that puts you in the X-shell before running the Y command that needs to be run in this X-shell?





...


(in your C++ code)





execve("/bin/example/myscript",...)





...





/bin/example/myscript looks like:





#/bin/X /* putting you in the X-shell */





Y-command /* running the actuall Y command here */








Any way, this is off the top of my head but maybe it'll help a little bit.


No comments:

Post a Comment