mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:25:06 +00:00
mkfifo: Port to LibMain
This commit is contained in:
parent
c10abd6be2
commit
b4d55f2a55
2 changed files with 9 additions and 11 deletions
|
@ -129,6 +129,7 @@ target_link_libraries(markdown-check LibMarkdown)
|
||||||
target_link_libraries(matroska LibVideo)
|
target_link_libraries(matroska LibVideo)
|
||||||
target_link_libraries(md LibMarkdown)
|
target_link_libraries(md LibMarkdown)
|
||||||
target_link_libraries(mkdir LibMain)
|
target_link_libraries(mkdir LibMain)
|
||||||
|
target_link_libraries(mkfifo LibMain)
|
||||||
target_link_libraries(mknod LibMain)
|
target_link_libraries(mknod LibMain)
|
||||||
target_link_libraries(nc LibMain)
|
target_link_libraries(nc LibMain)
|
||||||
target_link_libraries(netstat LibMain)
|
target_link_libraries(netstat LibMain)
|
||||||
|
|
|
@ -5,29 +5,26 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <stdio.h>
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio dpath", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio dpath"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mode_t mode = 0666;
|
mode_t mode = 0666;
|
||||||
Vector<const char*> paths;
|
Vector<StringView> paths;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
// FIXME: add -m for file modes
|
// FIXME: add -m for file modes
|
||||||
args_parser.add_positional_argument(paths, "Paths of FIFOs to create", "paths");
|
args_parser.add_positional_argument(paths, "Paths of FIFOs to create", "paths");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
int exit_code = 0;
|
int exit_code = 0;
|
||||||
|
|
||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
if (mkfifo(path, mode) < 0) {
|
auto error_or_void = Core::System::mkfifo(path, mode);
|
||||||
|
if (error_or_void.is_error()) {
|
||||||
perror("mkfifo");
|
perror("mkfifo");
|
||||||
exit_code = 1;
|
exit_code = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue