mkfifo: Port to LibMain
This commit is contained in:
parent
c10abd6be2
commit
b4d55f2a55
Notes:
sideshowbarker
2024-07-17 20:19:22 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/b4d55f2a552 Pull-request: https://github.com/SerenityOS/serenity/pull/11896 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bgianfo ✅ Reviewed-by: https://github.com/linusg
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(md LibMarkdown)
|
||||
target_link_libraries(mkdir LibMain)
|
||||
target_link_libraries(mkfifo LibMain)
|
||||
target_link_libraries(mknod LibMain)
|
||||
target_link_libraries(nc LibMain)
|
||||
target_link_libraries(netstat LibMain)
|
||||
|
|
|
@ -5,29 +5,26 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <stdio.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.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) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio dpath"));
|
||||
|
||||
mode_t mode = 0666;
|
||||
Vector<const char*> paths;
|
||||
Vector<StringView> paths;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
// FIXME: add -m for file modes
|
||||
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;
|
||||
|
||||
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");
|
||||
exit_code = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue