Modifying the environment variables of a parent process
Dear Mentors,
First of all I like to ask your patience because this is the first time
that I am using mailing lists. I hope that my issue has been in the
right place. The problem is related to the environment variables.
(Debian, Ubuntu) Is given some executable which is written in C. These
programs are perform various type of mathematical operations like as
calculate the quotient of two complex number or calculate the arcus
sin(x) of a real or complex number and so on... All of these "functions"
could be used within a bash script as we want it.
//-----------------------------------------------------------------------------------------
// two current terminal example
//-----------------------------------------------------------------------------------------
user@user:-$ cdiv -1 5 6 0
-0.16667 + j0.8333
user@user:-$ A=-1
user@user:-$ B=6
user@user:-$ cdiv $A 5 $B 0
-0.16667 + j0.8333
user@user:-$
//-----------------------------------------------------------------------------------------
This is the point when my problem is start.
If a result is born by an executable than it would be necessary to store
it from an environment variable which is located in the parent process
environment table. For this reason would be created two general
environment variable in the parent process " AC " and " ACIM "during the
initialization. (Or created by an executable if they is not exist yet)
These variables just like the CPU accumulator register. The " AC " is
the general(real) variable which is contains the results of all real
calculations and the "ACIM " is an ad-hoc(imaginary) variable which is
used in case of complex results. But somehow it is need to export the C
variables from the C code -which is contains the result(s)- into a
parent environment variable(s). How to modifying the environment
variables of a parent process from a C code?
//-----------------------------------------------------------------------------------------
// the desired effect
//-----------------------------------------------------------------------------------------
// initialization - if it is needed
//-----------------------------------------------------------------------------------------
user@user:-$ cdiv -1 5 6 0
-0.16667 + j0.8333
user@user:-$ echo $AC
-0.16667
user@user:-$ echo $ACIM
0.8333
user@user:-$ A=-1
user@user:-$ B=6
user@user:-$ cdiv $A 5 $B 0
-0.16667 + j0.8333
user@user:-$ echo $AC
-0.16667
user@user:-$ echo $ACIM
0.8333
user@user:-$
//-----------------------------------------------------------------------------------------
According to my current knowledge, It is not possible to set an
environment variables of a parent process from lower levels officially.
Anyway, I hope that the solution is exist and I will find it by
someone's help.
Thank you for your help and wish you all the bests
Warm regards
Peter
Reply to: