Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - pidin env: (8 Items)
   
pidin env  
I'm been using code from pidin env to get access to other processes environment variables.  My problem is with parsing 
of the data. Say a variable is setup like 

VAR="see the=sign "

This make parsing close to impossible.  Suggestions?

AW: pidin env  
Seek for the first '='.  Everything to the left is the variable's
name, everything to the right up to the terminating ASCII NUL is 
the value:

void getit( const char *env_var_val ) {
   char *name = strdup( env_var_val );
   char *value = strchr( name, '=' );
   *value++ = '\0';
   printf( "Variable '%s' has value '%s'\n", name, value );
}
   

Or did I miss your point?

- Thomas

> -----Ursprungliche Nachricht-----
> Von: Mario Charest [mailto:community-noreply@qnx.com]
> Gesendet: 23 September 2008 15:51
> An: ostech-core_os
> Betreff: pidin env
> 
> 
> I'm been using code from pidin env to get access to other 
> processes environment variables.  My problem is with parsing 
> of the data. Say a variable is setup like 
> 
> VAR="see the=sign "
> 
> This make parsing close to impossible.  Suggestions?
> 
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post13854
> 
> 
Re: AW: pidin env  
> 
> Seek for the first '='.  Everything to the left is the variable's
> name, everything to the right up to the terminating ASCII NUL is 
> the value:
> 
> void getit( const char *env_var_val ) {
>    char *name = strdup( env_var_val );
>    char *value = strchr( name, '=' );
>    *value++ = '\0';
>    printf( "Variable '%s' has value '%s'\n", name, value );
> }
>    
> 
> Or did I miss your point?

Yes and no. My example wasn't clear and I'm the one that got confuse.  I had modify Environment() ( as found in 
pidin_proc.c ) to return one big string instead of going to stdout.  I was trying to parse that string which separated 
the variables with spaces and not '\0', making it impossible to parse reliably.

I just realize that Environment() is getting each variable one by one.

Sorry about that.

> 
> - Thomas
> 
> > -----Ursprungliche Nachricht-----
> > Von: Mario Charest [mailto:community-noreply@qnx.com]
> > Gesendet: 23 September 2008 15:51
> > An: ostech-core_os
> > Betreff: pidin env
> > 
> > 
> > I'm been using code from pidin env to get access to other 
> > processes environment variables.  My problem is with parsing 
> > of the data. Say a variable is setup like 
> > 
> > VAR="see the=sign "
> > 
> > This make parsing close to impossible.  Suggestions?
> > 
> > 
> > 
> > _______________________________________________
> > OSTech
> > http://community.qnx.com/sf/go/post13854
> > 
> > 


AW: AW: pidin env  
Glad to hear you got what you wanted, though  :)

Cheers,
- Thomas

> -----Ursprungliche Nachricht-----
> Von: Mario Charest [mailto:community-noreply@qnx.com]
> Gesendet: 23 September 2008 16:54
> An: ostech-core_os
> Betreff: Re: AW: pidin env
> 
> 
> > 
> > Seek for the first '='.  Everything to the left is the variable's
> > name, everything to the right up to the terminating ASCII NUL is 
> > the value:
> > 
> > void getit( const char *env_var_val ) {
> >    char *name = strdup( env_var_val );
> >    char *value = strchr( name, '=' );
> >    *value++ = '\0';
> >    printf( "Variable '%s' has value '%s'\n", name, value );
> > }
> >    
> > 
> > Or did I miss your point?
> 
> Yes and no. My example wasn't clear and I'm the one that got 
> confuse.  I had modify Environment() ( as found in 
> pidin_proc.c ) to return one big string instead of going to 
> stdout.  I was trying to parse that string which separated 
> the variables with spaces and not '\0', making it impossible 
> to parse reliably.
> 
> I just realize that Environment() is getting each variable one by one.
> 
> Sorry about that.
> 
> > 
> > - Thomas
> > 
> > > -----Ursprungliche Nachricht-----
> > > Von: Mario Charest [mailto:community-noreply@qnx.com]
> > > Gesendet: 23 September 2008 15:51
> > > An: ostech-core_os
> > > Betreff: pidin env
> > > 
> > > 
> > > I'm been using code from pidin env to get access to other 
> > > processes environment variables.  My problem is with parsing 
> > > of the data. Say a variable is setup like 
> > > 
> > > VAR="see the=sign "
> > > 
> > > This make parsing close to impossible.  Suggestions?
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > OSTech
> > > http://community.qnx.com/sf/go/post13854
> > > 
> > > 
> 
> 
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post13863
> 
> 
Re: pidin env  
> I'm been using code from pidin env to get access to other processes 
> environment variables.  My problem is with parsing of the data. Say a variable
>  is setup like 
> 
> VAR="see the=sign "
> 
> This make parsing close to impossible.  Suggestions?
> 


While I'm at it, let me steal my own post ;-)

Any way to speed up reading of environment variable across the network.  It currently takes 300ms to read about 30 
variables.
Re: pidin env  
Mario - it's basically just reading /proc/pid/as across the network - is it simply that pidin env is doing it 
inefficiently?

Mario Charest wrote:
>> I'm been using code from pidin env to get access to other processes 
>> environment variables.  My problem is with parsing of the data. Say a variable
>>  is setup like 
>>
>> VAR="see the=sign "
>>
>> This make parsing close to impossible.  Suggestions?
>>
> 
> 
> While I'm at it, let me steal my own post ;-)
> 
> Any way to speed up reading of environment variable across the network.  It currently takes 300ms to read about 30 
variables.
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post13887
> 

-- 
cburgess@qnx.com
Re: pidin env  
> Mario - it's basically just reading /proc/pid/as across the network - is it 
> simply that pidin env is doing it inefficiently?

Yes could be, it's doing lots of lseek64 and small reads.   Not sure how that can be improved though. Seems to me that 
is the nature of the beast.
Re: pidin env  
Yes, it's reading the initial stack to get argc, then it's reading past the argv vectors, then it's reading the env 
vectors, then
for each one it's reading the env value.

Ewww!

Mario Charest wrote:
>> Mario - it's basically just reading /proc/pid/as across the network - is it 
>> simply that pidin env is doing it inefficiently?
> 
> Yes could be, it's doing lots of lseek64 and small reads.   Not sure how that can be improved though. Seems to me that
 is the nature of the beast.
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post13892
> 

-- 
cburgess@qnx.com