* More generous buffer sizes for the semaphore and shared memory object names.

* The result shared memory was mapped PROT_WRITE only, but since the variable in
  it is used with the increment operator, it needs PROT_READ, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36089 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-04-08 17:15:49 +00:00
parent baa26c5b4c
commit d7754ff079
@@ -40,7 +40,7 @@
#include <unistd.h> #include <unistd.h>
#include "posixtest.h" #include "posixtest.h"
#define NAME_SIZE 20 #define NAME_SIZE 50
#define SHM_NAME "/posixtest_23-1_%d" #define SHM_NAME "/posixtest_23-1_%d"
/* The processes communicate by a shared memory object */ /* The processes communicate by a shared memory object */
@@ -81,9 +81,9 @@ int child_func(void)
int main() { int main() {
int i, pid, result_fd; int i, pid, result_fd;
char semname[20]; char semname[50];
snprintf(semname, 20, "/sem23-1_%ld", (long)getpid()); snprintf(semname, sizeof(semname), "/sem23-1_%ld", (long)getpid());
sem = sem_open(semname, O_CREAT, 0777, 1); sem = sem_open(semname, O_CREAT, 0777, 1);
if( sem == SEM_FAILED || sem == NULL ) { if( sem == SEM_FAILED || sem == NULL ) {
perror("error at sem_open"); perror("error at sem_open");
@@ -105,7 +105,7 @@ int main() {
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
} }
create_cnt = mmap(NULL, sizeof(*create_cnt), PROT_WRITE, create_cnt = mmap(NULL, sizeof(*create_cnt), PROT_READ | PROT_WRITE,
MAP_SHARED, result_fd, 0); MAP_SHARED, result_fd, 0);
if( create_cnt == MAP_FAILED) { if( create_cnt == MAP_FAILED) {
perror("An error occurs when calling mmap()"); perror("An error occurs when calling mmap()");