This commit is contained in:
Ivanov Matvey 2025-01-09 22:45:54 +10:00
parent 87072f3a6a
commit 5fec83ce94
3 changed files with 1 additions and 30 deletions

View File

@ -7,6 +7,6 @@ project(hello-world-cpp) # Название проекта
add_library(process_launcher STATIC process_launcher.cpp) # Создание статической библиотеки с именем process_launcher add_library(process_launcher STATIC process_launcher.cpp) # Создание статической библиотеки с именем process_launcher
add_executable(main test.cpp) # Создает исполняемый файл с именем main add_executable(main main.cpp) # Создает исполняемый файл с именем main
target_link_libraries(main process_launcher) # Линковка программы с библиотекой target_link_libraries(main process_launcher) # Линковка программы с библиотекой

BIN
README.md

Binary file not shown.

View File

@ -1,29 +0,0 @@
#include "process_launcher.h"
#include <iostream>
#include <string>
int main() {
std::string command;
// В зависимости от ОС, выберем команду для запуска
#ifdef _WIN32
command = "cmd /C echo Hello, World!";
#else
command = "echo Hello, World!";
#endif
// Запускаем процесс
int pid = ProcessLauncher::launch(command);
if (pid == -1) {
std::cerr << "Не удалось запустить процесс." << std::endl;
return -1;
}
std::cout << "Процесс с PID: " << pid << " запущен." << std::endl;
// Ожидаем завершения процесса
int exitCode = ProcessLauncher::waitForProcess(pid);
std::cout << "Процесс завершился с кодом: " << exitCode << std::endl;
return 0;
}