version 1.74, 2016/03/17 16:31:58
|
version 1.90, 2021/03/13 12:50:52
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.25 |
RPL/2 (R) version 4.1.33 |
Copyright (C) 1989-2016 Dr. BERTRAND Joël |
Copyright (C) 1989-2021 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 76 sem_init2(unsigned int valeur, pid_t pid
|
Line 76 sem_init2(unsigned int valeur, pid_t pid
|
sem_t *semaphore; |
sem_t *semaphore; |
|
|
unsigned char *chemin; |
unsigned char *chemin; |
|
unsigned char *langue; |
|
|
if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) |
if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) |
{ |
{ |
return(SEM_FAILED); |
return(SEM_FAILED); |
} |
} |
|
|
semaphore = sem_open(chemin, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, |
if ((semaphore = sem_open(chemin, O_RDWR | O_CREAT | O_EXCL, |
valeur); |
S_IRUSR | S_IWUSR, valeur)) == SEM_FAILED) |
|
{ |
|
if (errno == EEXIST) |
|
{ |
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Attention : Le sémaphore %s préexiste !\n", |
|
chemin); |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", chemin); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", chemin); |
|
} |
|
|
|
if (sem_unlink(chemin) != 0) |
|
{ |
|
sys_free(chemin); |
|
return(SEM_FAILED); |
|
} |
|
|
|
semaphore = sem_open(chemin, O_RDWR | O_CREAT | O_EXCL, |
|
S_IRUSR | S_IWUSR, valeur); |
|
} |
|
} |
|
|
sys_free(chemin); |
sys_free(chemin); |
|
|
return(semaphore); |
return(semaphore); |
Line 96 sem_init3(unsigned int valeur, pid_t pid
|
Line 128 sem_init3(unsigned int valeur, pid_t pid
|
sem_t *semaphore; |
sem_t *semaphore; |
|
|
unsigned char *chemin; |
unsigned char *chemin; |
|
unsigned char *langue; |
|
|
if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) |
if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) |
{ |
{ |
return(SEM_FAILED); |
return(SEM_FAILED); |
} |
} |
|
|
semaphore = sem_open(chemin, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR, |
if ((semaphore = sem_open(chemin, O_RDWR | O_CREAT | O_EXCL, |
valeur); |
S_IRUSR | S_IWUSR, valeur)) == SEM_FAILED) |
|
{ |
|
if (errno == EEXIST) |
|
{ |
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Attention : Le sémaphore %s préexiste !\n", |
|
chemin); |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", chemin); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", chemin); |
|
} |
|
|
|
semaphore = sem_open(chemin, O_RDWR | O_CREAT, |
|
S_IRUSR | S_IWUSR, valeur); |
|
} |
|
} |
|
|
sys_free(chemin); |
sys_free(chemin); |
|
|
return(semaphore); |
return(semaphore); |
Line 226 sem_getvalue2(sem_t *semaphore, int *val
|
Line 284 sem_getvalue2(sem_t *semaphore, int *val
|
return(0); |
return(0); |
} |
} |
|
|
|
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
} |
} |
|
|
Line 277 sem_init_SysV(sem_t *semaphore, int shar
|
Line 336 sem_init_SysV(sem_t *semaphore, int shar
|
|
|
union semun argument; |
union semun argument; |
|
|
|
unsigned char *langue; |
|
|
if (shared == 0) |
if (shared == 0) |
{ |
{ |
// Sémaphore privé |
// Sémaphore privé |
Line 304 sem_init_SysV(sem_t *semaphore, int shar
|
Line 365 sem_init_SysV(sem_t *semaphore, int shar
|
if ((desc = open((*semaphore).path, O_RDWR | O_CREAT | O_EXCL, |
if ((desc = open((*semaphore).path, O_RDWR | O_CREAT | O_EXCL, |
S_IRUSR | S_IWUSR)) == -1) |
S_IRUSR | S_IWUSR)) == -1) |
{ |
{ |
sys_free((*semaphore).path); |
if (errno != EEXIST) |
return(-1); |
{ |
|
sys_free((*semaphore).path); |
|
return(-1); |
|
} |
|
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Attention : Le sémaphore %s préexiste !\n", |
|
(*semaphore).path); |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", |
|
(*semaphore).path); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", |
|
(*semaphore).path); |
|
} |
|
|
|
if ((desc = open((*semaphore).path, O_RDWR | O_CREAT, |
|
S_IRUSR | S_IWUSR)) == -1) |
|
{ |
|
sys_free((*semaphore).path); |
|
return(-1); |
|
} |
} |
} |
|
|
(*semaphore).pid = getpid(); |
(*semaphore).pid = getpid(); |
Line 701 sem_t
|
Line 791 sem_t
|
key_t clef; |
key_t clef; |
|
|
union semun argument; |
union semun argument; |
|
|
|
unsigned char *langue; |
# endif |
# endif |
|
|
unsigned char *nom_absolu; |
unsigned char *nom_absolu; |
Line 891 sem_t
|
Line 983 sem_t
|
if ((desc = open(nom_absolu, O_CREAT | O_EXCL | O_RDWR, |
if ((desc = open(nom_absolu, O_CREAT | O_EXCL | O_RDWR, |
S_IRUSR | S_IWUSR)) == -1) |
S_IRUSR | S_IWUSR)) == -1) |
{ |
{ |
sys_free(semaphore); |
if (errno != EEXIST) |
sys_free(nom_absolu); |
{ |
|
sys_free(semaphore); |
|
sys_free(nom_absolu); |
|
return(SEM_FAILED); |
|
} |
|
|
return(SEM_FAILED); |
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Attention : Le sémaphore %s préexiste !\n", |
|
nom_absolu); |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", |
|
nom_absolu); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++Warning: %s semaphore preexists!\n", |
|
nom_absolu); |
|
} |
|
|
|
if ((desc = open(nom_absolu, O_CREAT | O_RDWR, |
|
S_IRUSR | S_IWUSR)) == -1) |
|
{ |
|
sys_free(semaphore); |
|
sys_free(nom_absolu); |
|
return(SEM_FAILED); |
|
} |
} |
} |
|
|
if ((clef = ftok(nom_absolu, 1)) == -1) |
if ((clef = ftok(nom_absolu, 1)) == -1) |