中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站開發(fā)日常工作廊坊seo推廣

網(wǎng)站開發(fā)日常工作,廊坊seo推廣,自己做一個網(wǎng)站要多少錢,設(shè)計素材網(wǎng)站能掙錢嗎Linux進(jìn)程編程(PS: exec族函數(shù)、system、popen函數(shù))_linux popen函數(shù)會新建進(jìn)程嗎-CSDN博客 execvp函數(shù)詳解_如何在C / C 中使用execvp()函數(shù)-CSDN博客 C語言的多進(jìn)程fork()、函數(shù)exec*()、system()與popen()函數(shù)_c語言 多進(jìn)程-CSDN博客 Linux---fork…

Linux進(jìn)程編程(PS: exec族函數(shù)、system、popen函數(shù))_linux popen函數(shù)會新建進(jìn)程嗎-CSDN博客

execvp函數(shù)詳解_如何在C / C ++中使用execvp()函數(shù)-CSDN博客

C語言的多進(jìn)程fork()、函數(shù)exec*()、system()與popen()函數(shù)_c語言 多進(jìn)程-CSDN博客

Linux---fork函數(shù)和exec函數(shù)_fork exec-CSDN博客

#include <unistd.h>int main() {pid_t childPid = fork(); //創(chuàng)建子進(jìn)程if (childPid == -1) {perror("fork");return 1;} else if (childPid == 0) {// 子進(jìn)程的代碼char* args[] = {"/bin/sh", "-c", "logcat | grep", NULL};int result = execvp(args[0], args);if (result == -1) {perror("execvp");exit(EXIT_FAILURE);}} else {// 父進(jìn)程的代碼waitpid(childPid, NULL, 0); //等待子進(jìn)程結(jié)束}return 0;
}

#include <iostream>
#include <stdio.h>
#include <unistd.h> // for getpid() function
#include <sys/wait.h>
#include <string.h>
#include <chrono>
#include <thread>
#include <unistd.h>#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>int main() {char *p = (char*)malloc(5000);strcpy(p, "ifsddsffdsdsdfsfdssdffds");pid_t pid = fork(); // 創(chuàng)建子進(jìn)程if (pid > 0) {int status;// wait(&status); // 等待子進(jìn)程結(jié)束std::this_thread::sleep_for(std::chrono::milliseconds(3000));// std::string cmd_str = "kill -9  " + std::to_string(pid);//pkill -TERM -P 27888std::string cmd_str = "pkill -TERM -P  " + std::to_string(pid);auto ret = system(cmd_str.c_str());std::cout << "Child process ID is: " << pid << std::endl;} else if (pid == 0) {char *a = (char*)malloc(100);// std::this_thread::sleep_for(std::chrono::milliseconds(3000));#if 1std::string cmd_log = "/home/zeekr/code/test/test";// 關(guān)閉標(biāo)準(zhǔn)輸入、輸出和錯誤流close(STDIN_FILENO);close(STDOUT_FILENO);close(STDERR_FILENO);// 打開要寫入的文件int fd = open("output.txt", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);// 設(shè)置新的標(biāo)準(zhǔn)輸出為指定文件dup2(fd, STDOUT_FILENO);// 執(zhí)行需要重定向的命令// execlp("/bin/ls", "ls", "-la", NULL);// execlp(cmd_log.c_str(), "test", "3", NULL);// execl(cmd_log.c_str(),"test", "3", ">a.txt 2>&1",NULL);char* args[] = {"/bin/sh", "-c", "logcat | grep xxx", NULL};int result = execvp(args[0], args);if (result == -1) {perror("execvp");exit(EXIT_FAILURE);}// execl("/bin/ls", "ls", "-l", NULL);perror("Child failed to exec ls");//execl后面的代碼都不會執(zhí)行了printf("chlid end\n");exit(0);//讓子進(jìn)程到這里就結(jié)束#elif 0std::string cmd_log = "top > a.txt  2>&1 ";auto status = system(cmd_log.c_str());printf("system: %d\n", status);std::this_thread::sleep_for(std::chrono::milliseconds(30000));printf("exit(EXIT_SUCCESS);\n");exit(EXIT_SUCCESS);#elif 0std::string cmd_log = "top > a.txt  2>&1 ";FILE* pipe = popen(cmd_log.c_str(), "r"); // 這里以"ls"命令為例,也可以根據(jù)需求修改成其他命令或腳本if (pipe == nullptr) {std::cout << "Failed to create child process." << std::endl;return -1;}// 子進(jìn)程部分char buffer[256];while (!feof(pipe)) {fgets(buffer, sizeof(buffer), pipe);printf("result: %s\n", buffer);}pclose(pipe); // 關(guān)閉管道printf("pclose(pipe); : %s\n", buffer);exit(EXIT_SUCCESS);
#endif} else {std::cerr << "Fork failed!" << std::endl;return -1;}return 0;
}

http://www.risenshineclean.com/news/41239.html

相關(guān)文章:

  • wordpress調(diào)用分類圖片大小長沙靠譜的關(guān)鍵詞優(yōu)化
  • 海外域名提示風(fēng)險網(wǎng)站嗎成都網(wǎng)站seo服務(wù)
  • 濟(jì)南網(wǎng)站建設(shè)維護(hù)公司關(guān)鍵詞挖掘工具網(wǎng)站
  • 哪些調(diào)查網(wǎng)站可以做問卷賺錢可以訪問境外的瀏覽器
  • 瑪伊網(wǎng)站做兼職加入要多少錢推廣哪個平臺好
  • b2b商城網(wǎng)站建設(shè)百度關(guān)鍵詞推廣多少錢
  • 做電影網(wǎng)站怎么掙錢下店拓客團(tuán)隊(duì)
  • 百通互聯(lián)網(wǎng)站建設(shè)免費(fèi)下優(yōu)化大師
  • 網(wǎng)站建設(shè)方案應(yīng)該怎么做網(wǎng)站友鏈
  • 做網(wǎng)站賣假名牌違法嗎網(wǎng)站建設(shè)建站在線建站
  • 委托別人做網(wǎng)站 域名所有權(quán)2021年新聞?wù)?/a>
  • 企業(yè)網(wǎng)站建設(shè)基本步驟沈陽網(wǎng)站關(guān)鍵字優(yōu)化
  • 找個人做網(wǎng)站還是找企業(yè)做網(wǎng)站自己如何優(yōu)化網(wǎng)站排名
  • 廣西做網(wǎng)站的公司有哪些谷歌關(guān)鍵詞工具
  • 網(wǎng)站建設(shè)系統(tǒng)哪家便宜些seo廣告平臺
  • 手表到哪個網(wǎng)站買新網(wǎng)站應(yīng)該怎么做seo
  • 天河做網(wǎng)站哪家好沒干過網(wǎng)絡(luò)推廣能干嗎
  • 通遼做網(wǎng)站制作公司一個公司可以做幾個百度推廣
  • 網(wǎng)購app有哪些?長沙seo計費(fèi)管理
  • 網(wǎng)站設(shè)計的總結(jié)深圳網(wǎng)站快速排名優(yōu)化
  • 免費(fèi)建站網(wǎng)站大全長沙網(wǎng)站推廣seo
  • 網(wǎng)站建設(shè)后臺是什么推廣聯(lián)盟平臺
  • 購物網(wǎng)站開發(fā)實(shí)戰(zhàn)企業(yè)網(wǎng)站優(yōu)化排名
  • 做國際貿(mào)易都用什么網(wǎng)站seo優(yōu)化排名是什么
  • 網(wǎng)站建設(shè)驗(yàn)收標(biāo)準(zhǔn)銷售推廣方案
  • 烏魯木齊培訓(xùn)網(wǎng)站建設(shè)網(wǎng)站自然優(yōu)化
  • 黃驊市第三中學(xué)關(guān)鍵詞優(yōu)化包年推廣
  • 如何寫一個可以做報價計算的網(wǎng)站網(wǎng)絡(luò)服務(wù)網(wǎng)絡(luò)推廣
  • 為什么自己做的網(wǎng)站別的電腦打不開廣州新聞最新消息今天
  • 怎么做游戲自動充值的網(wǎng)站重慶高端網(wǎng)站seo