Problem setenv/putenv for msgget

Martine Carannante Martine.Carannante@bull.net
Tue Mar 28 09:17:00 GMT 2006


I 'm using CYGWIN (the last version 1.5.19.4). My application use the 
IPC messages queue.

The cygserver is started correctly.
The application server side (is a service)  is launched by cygrunsrv ... 
with -e CYGWIN=server , it is OK
If I launch the application client in a shell script, it is OK if I set 
before launching the application,  the CYGWIN variable to server. It's 
normal.

My problem is :
----------------------
   - The application client is a CGI written in C, launched by Apache or 
IIS  , and I don't know how to set the CYGWIN variable before the 
application is launched.If I use Apache I can use the SetEnv directive 
to set a variable in the  Apache configuration file. But with IIS  I 
don't know  to do that. I need a global solution for Apache and IIS.

So , I tried to set the environment variable CYGWIN to server with  the 
routines setenv(), putenv(), SetEnvironmentVariable() inside the CGI 
code. I have always the "Bad system call " error when the program 
executes msgget. It seems that the setenv function doesn't run while the 
getenv function returns the right value !!

I wrote a test program to reproduce the problem:
    - rcv_msg.c waits for messages
    - send_msg.c sends messages
The test programs are launched in a shell window.

_Test NOK
_The variable CYGWIN is set in the shell for the server rcv_msg .
The variable CYGWIN is set inside the  send_msg.c  program (setenv routine)
The file /tmp/xx must exist. The programs are launched in 2 different 
shell windows

/$/ */export CYGWIN=server/*
/$ ./rcv_msg.exe /tmp/xx
Call ftok /tmp/xx
command_file=/tmp/xx,key=16068417
Call msgget
Return msgget 3538944
Loop msgrcv

$ *unset CYGWIN*
$ ./send_msg.exe /tmp/xx AAA
Call getenv CYGWIN
Value returned by getenv CYGWIN =(null)
Call setenv CYGWIN=server
Value returned by setenv CYGWIN result=0
Call getenv CYGWIN
Value returned by getenv CYGWIN =server
Call msgget
Bad system call


/_Test OK (CYGWIN variable set in the shell for the server and client 
application ): _
/$/ */export CYGWIN=server/*
/$ ./rcv_msg.exe /tmp/xx
Call ftok /tmp/xx
command_file=/tmp/xx,key=16068417
Call msgget
Return msgget 3538944
Loop msgrcv
Message=AAA

//$/* /export CYGWIN=server/*
/$ ./send_msg.exe /tmp/xx AAA
Call getenv CYGWIN
Value returned by getenv CYGWIN =(null)
Call setenv CYGWIN=server
Value returned by setenv CYGWIN result=0
Call getenv CYGWIN
Value returned by getenv CYGWIN =server
Call msgget/

_Note:_  I used ipc-daemon in my previous version, and it was OK. There was no environment variable to set.

Thanks to help me.
Martine

-- 
Martine Carannante
System Software Development R&D 

Bull, Architect of an Open World TM 

Tél : (+33) 1 30 80 71 87
http://www.bull.com 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rcv_msg.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060328/6386eb91/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: send_msg.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060328/6386eb91/attachment-0001.c>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list