This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cygipc problem (was shmctl(blabla,IPC_RMID,NULL) question)


Sergey,

Please post instead of sending private email.

Thanks,
Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
--- Begin Message --- Dear Jason,
I've got some issues with IPC_RMID under cygwin, I got cygipc1.4.
Under Linux it works perfect but under windows it doesn't remove the
schmid.
First you have to start ipctest then start getshm. Find them in attach.
The first one allocates the memory writes the pid to it and the other
gets the memory removes the shmid and kills the previous application by the pid.
very simple.
Then when I start ipcs it shows me that the identifer wasn't removed
though it didn't write me any error in shmctl. T
hen I have to remove the identifer by hand
with ipcrm.
What could that be?


thank you for your response
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>


int main(int argc,char *argv){

int shmid;
    key_t key;
    char *shm, *s;

    /*
     * We need to get the segment named
     * "5678", created by the server.
     */
    key = 5000;

    /*
     * Locate the segment.
     */
    if ((shmid = shmget(key, 0x2, 0666)) < 0) {
        perror("shmget");
        exit(1);
    }
printf("get shmid = %d\n",shmid);
    /*
     * Now we attach the segment to our data space.
     */
    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
        perror("shmat");
        exit(1);
    }

printf("pid of other proc = %s\n",shm);


if(!shmctl(shmid,IPC_RMID,NULL))
perror("shmctl");

if(kill(atoi(shm),SIGINT)!=0)
perror("cant kill");


}
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <strings.h>

int main (int argc, char* argv[]){
pid_t pid = getpid ();
key_t key = 5000;
char *shmem;
int shmid;
shmid= shmget (key,0x400,IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR);

printf("shmid : %d\n",shmid);
printf("pid : %d\n",pid);

shmem = (char *)shmat(shmid,0,0);

sprintf(shmem,"%d",pid);
printf("shmem : %s\n",shmem);

shmdt(shmem);

for(;;)
pause();


shmctl (shmid, IPC_RMID, 0);
}


--- End Message ---
--
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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]