The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Wild card in find perm braindrain Shell Programming and Scripting 1 04-12-2007 03:24 PM
perm bits mpang_ Shell Programming and Scripting 1 02-10-2007 06:17 AM
find -perm query napolayan UNIX for Dummies Questions & Answers 1 11-28-2006 10:28 AM
Semaphore vjsony UNIX for Dummies Questions & Answers 3 04-07-2003 11:06 AM
semaphore yls177 UNIX for Dummies Questions & Answers 1 10-08-2002 08:18 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-06-2006
Registered User
 

Join Date: Jun 2004
Location: Italia - Napoli
Posts: 6
change semaphore perm

Hi,

I've a problem with this simple code about of semaphore:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<semaphore.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<sys/fcntl.h>

#define SemName "/SEM_1"   

int main (int argc, char **argv)
{
   char name[20];
   sem_t *semdes;
   sprintf(name, SemName);
   printf("\nSto creando il semaforo %s...\t", name);
   semdes = sem_open(name, O_CREAT | O_EXCL, 0666, 1);  // crea il semaforo
   printf("Semaforo %s creato!\n\n", name);

}
The code is ok, but now I would a way to view/change the perms of the semaphore.... And really I don't know a way to do it.

Can anyone show me a way to do it...?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-07-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,491
Do you mean sem_getvalue or are you thinking about changing permissions?
Reply With Quote
  #3 (permalink)  
Old 06-07-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,474
is it that you want to change the permissions of the sem ?

change it that at the time of sem_creation itself !!!!

or is it that you want to change the perms once it is created ???
Reply With Quote
  #4 (permalink)  
Old 06-07-2006
Registered User
 

Join Date: Jun 2004
Location: Italia - Napoli
Posts: 6
Quote:
Originally Posted by jim mcnamara
Do you mean sem_getvalue or are you thinking about changing permissions?
I'm thinking about changing permissions....
Reply With Quote
  #5 (permalink)  
Old 06-07-2006
Registered User
 

Join Date: Jun 2004
Location: Italia - Napoli
Posts: 6
Quote:
Originally Posted by matrixmadhan
change it that at the time of sem_creation itself !!!!
I want change it AFTER the sem creation...
Reply With Quote
  #6 (permalink)  
Old 06-07-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,491
There is some confusion here. sem_open creates the semaphore in memory using it's own rules. The named semaphore can be accessed as long as the other process knows the name of the semaphore.

If you want to change things, then you will have to created shared memory, like you get with shmget then maybe calling shmat, and create your own mutex or semphore there.

You can't change protection on the memory allocated with sem_open and it's family of calls.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0