*
* 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 <sys/types.h> /* primitive system data types */
-#include <sys/stat.h>
-#include <dirent.h> /* directory */
-#include <stdlib.h> /* C standard library */
-#include <unistd.h> /* unix standard library */
-#include <stdio.h> /* standard I/O library */
+#include <sys/types.h> /* primitive system data types */
+#include <sys/stat.h> /* file characteristics constants and functions */
+#include <dirent.h> /* directory operation constants and functions */
+#include <stdlib.h> /* C standard library */
+#include <unistd.h> /* unix standard library */
+#include <stdio.h> /* standard I/O library */
#include "Gapil.h"
#include "macros.h"
/*
* 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();
}
}
* 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;
}