Last active
December 31, 2017 20:58
-
-
Save filosofisto/3905fbf09befeee37e5bdc1cf61f154d to your computer and use it in GitHub Desktop.
Unlink (destroy) Posix Message Queue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.9) | |
project(posix_mq_unlink) | |
set(CMAKE_CXX_STANDARD 98) | |
set(GCC_COVERATE_LINK_FLAGS "-lrt") | |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERATE_LINK_FLAGS}") | |
add_executable(posix_mq_unlink main.cpp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
#include <cstdlib> | |
#include <mqueue.h> | |
using namespace std; | |
void usage(char **argv); | |
int main(int argc, char **argv) { | |
cout << "Posix Message unlink" << endl; | |
if (argc != 2 || strcmp(argv[1], "--help") == 0) { | |
usage(argv); | |
return EXIT_FAILURE; | |
} | |
if (mq_unlink(argv[1]) == -1) { | |
cerr << "Error to unlink message " << argv[1] << endl; | |
return EXIT_FAILURE; | |
} | |
cout << "unlinked of " << argv[1] << " successful" << endl; | |
return EXIT_SUCCESS; | |
} | |
void usage(char **argv) | |
{ | |
cout << "Usage: " << argv[0] << " <msgname>" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment