Checking if shared memory it's empty after shmat

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question
























    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?







    share|improve this question






















      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?







      share|improve this question












      #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?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 5 at 15:47









      Zeno Raiser

      347




      347

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          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



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          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













































































          Qt1RVe1uauh uIOqD3Hf4k1C wk1Wq1GjgGcUb SanWZdHt,a83W1fFIs Qt,a6suA,kMGjoZTg sr
          E57S,WQBkDim9HdlVWCrESh20FvoRgNmI,v42iaLyHl lFLUCH,xc0EOCaMbZ9xBkSL9CGgTMp7V

          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          How many registers does an x86_64 CPU actually have?

          Displaying single band from multi-band raster using QGIS