Checking if shared memory it's empty after shmat
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <semaphore.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#define TEST_ERROR if (errno) fprintf(stderr,
"%s:%d: PID=%5d: Error %d (%s)n",
__FILE__,
__LINE__,
getpid(),
errno,
strerror(errno));
struct individuals
pid_t writer;
;
struct shared_data
struct individuals vec[10];
;
int main()
int shm_people_id;
struct shared_data *people;
shm_people_id = shmget(IPC_PRIVATE, sizeof(*people), 0600);
TEST_ERROR;
printf("My shm_people_id is %dn", shm_people_id);
if((people = shmat(shm_people_id, NULL, 0)) == NULL)
printf("empty shmn");
shmctl(shm_people_id, IPC_RMID, NULL);
How can i check if a shared memory it's empty (by empty i mean without data putted in like in this code) after ataching to her?
c ipc shared-memory
add a comment |Â
up vote
0
down vote
favorite
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <semaphore.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#define TEST_ERROR if (errno) fprintf(stderr,
"%s:%d: PID=%5d: Error %d (%s)n",
__FILE__,
__LINE__,
getpid(),
errno,
strerror(errno));
struct individuals
pid_t writer;
;
struct shared_data
struct individuals vec[10];
;
int main()
int shm_people_id;
struct shared_data *people;
shm_people_id = shmget(IPC_PRIVATE, sizeof(*people), 0600);
TEST_ERROR;
printf("My shm_people_id is %dn", shm_people_id);
if((people = shmat(shm_people_id, NULL, 0)) == NULL)
printf("empty shmn");
shmctl(shm_people_id, IPC_RMID, NULL);
How can i check if a shared memory it's empty (by empty i mean without data putted in like in this code) after ataching to her?
c ipc shared-memory
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <semaphore.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#define TEST_ERROR if (errno) fprintf(stderr,
"%s:%d: PID=%5d: Error %d (%s)n",
__FILE__,
__LINE__,
getpid(),
errno,
strerror(errno));
struct individuals
pid_t writer;
;
struct shared_data
struct individuals vec[10];
;
int main()
int shm_people_id;
struct shared_data *people;
shm_people_id = shmget(IPC_PRIVATE, sizeof(*people), 0600);
TEST_ERROR;
printf("My shm_people_id is %dn", shm_people_id);
if((people = shmat(shm_people_id, NULL, 0)) == NULL)
printf("empty shmn");
shmctl(shm_people_id, IPC_RMID, NULL);
How can i check if a shared memory it's empty (by empty i mean without data putted in like in this code) after ataching to her?
c ipc shared-memory
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <semaphore.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#define TEST_ERROR if (errno) fprintf(stderr,
"%s:%d: PID=%5d: Error %d (%s)n",
__FILE__,
__LINE__,
getpid(),
errno,
strerror(errno));
struct individuals
pid_t writer;
;
struct shared_data
struct individuals vec[10];
;
int main()
int shm_people_id;
struct shared_data *people;
shm_people_id = shmget(IPC_PRIVATE, sizeof(*people), 0600);
TEST_ERROR;
printf("My shm_people_id is %dn", shm_people_id);
if((people = shmat(shm_people_id, NULL, 0)) == NULL)
printf("empty shmn");
shmctl(shm_people_id, IPC_RMID, NULL);
How can i check if a shared memory it's empty (by empty i mean without data putted in like in this code) after ataching to her?
c ipc shared-memory
asked Jan 5 at 15:47
Zeno Raiser
347
347
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Â
draft saved
draft discarded
Â
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f415014%2fchecking-if-shared-memory-its-empty-after-shmat%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password