X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FWriteShm.c;h=ce5ea496b357b79d257b6c9c4c066272e5917f09;hp=db5b132ff817643621d5cfa03bea3bffb812e009;hb=d451ac30382ae398b9a2242a4f82b3438affc8a7;hpb=31f55ec58bee8b2c4993633849b7da4e30cab222 diff --git a/sources/WriteShm.c b/sources/WriteShm.c index db5b132..ce5ea49 100644 --- a/sources/WriteShm.c +++ b/sources/WriteShm.c @@ -20,18 +20,18 @@ * * File WriteShm.c: * - * An example of POSIX shared memory use: wwrite some content to a + * An example of POSIX shared memory use: write some content to a * shared memory segment * * Author: S. Piccardi Jan. 2003 * *****************************************************************************/ -#include /* primitive system data types */ -#include -#include /* directory */ -#include /* C standard library */ -#include /* unix standard library */ -#include /* standard I/O library */ +#include /* primitive system data types */ +#include /* file characteristics constants and functions */ +#include /* directory operation constants and functions */ +#include /* C standard library */ +#include /* unix standard library */ +#include /* standard I/O library */ #include "Gapil.h" #include "macros.h" @@ -58,21 +58,21 @@ int main(int argc, char *argv[]) /* * Handling options */ - case 's': /* set pause (in sec.) */ + case 's': /* set pause (in sec.) */ size = strtol(optarg, NULL, 10); break; - case 'f': /* set pause (in sec.) */ + case 'f': /* set pause (in sec.) */ file_name = optarg; break; - case 'h': /* help option */ + case 'h': /* help option */ printf("Wrong -h option use\n"); usage(); return -1; break; - case '?': /* unrecognized options */ + case '?': /* unrecognized options */ printf("Unrecognized options -%c\n",optopt); usage(); - default: /* should not reached */ + default: /* should not reached */ usage(); } } @@ -83,12 +83,13 @@ int main(int argc, char *argv[]) * Main code beginning * * ***********************************************************/ - if ((argc - optind) != 1) { /* There must be remaing parameters */ + if ((argc - optind) != 1) { /* There must be remaing parameters */ printf("Wrong number of arguments %d\n", argc - optind); usage(); } + /* get a Mutex */ mutex_file = tempnam("/tmp","mutex"); - if ((mutex = CreateMutex(mutex_file)) == -1) { /* get a Mutex */ + if ((mutex = CreateMutex(mutex_file)) == -1) { perror("Cannot create mutex"); goto errmutex; }