当前位置: 首页 > news >正文

网页设计电商网站求网站

网页设计电商网站,求网站,用c 做网站在Linux上,网站seo推广怎么做Linux进程编程(PS: exec族函数、system、popen函数)_linux popen函数会新建进程吗-CSDN博客 execvp函数详解_如何在C / C 中使用execvp()函数-CSDN博客 C语言的多进程fork()、函数exec*()、system()与popen()函数_c语言 多进程-CSDN博客 Linux---fork…

Linux进程编程(PS: exec族函数、system、popen函数)_linux popen函数会新建进程吗-CSDN博客

execvp函数详解_如何在C / C ++中使用execvp()函数-CSDN博客

C语言的多进程fork()、函数exec*()、system()与popen()函数_c语言 多进程-CSDN博客

Linux---fork函数和exec函数_fork exec-CSDN博客

#include <unistd.h>int main() {pid_t childPid = fork(); //创建子进程if (childPid == -1) {perror("fork");return 1;} else if (childPid == 0) {// 子进程的代码char* args[] = {"/bin/sh", "-c", "logcat | grep", NULL};int result = execvp(args[0], args);if (result == -1) {perror("execvp");exit(EXIT_FAILURE);}} else {// 父进程的代码waitpid(childPid, NULL, 0); //等待子进程结束}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(); // 创建子进程if (pid > 0) {int status;// wait(&status); // 等待子进程结束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";// 关闭标准输入、输出和错误流close(STDIN_FILENO);close(STDOUT_FILENO);close(STDERR_FILENO);// 打开要写入的文件int fd = open("output.txt", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);// 设置新的标准输出为指定文件dup2(fd, STDOUT_FILENO);// 执行需要重定向的命令// 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后面的代码都不会执行了printf("chlid end\n");exit(0);//让子进程到这里就结束#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"命令为例,也可以根据需求修改成其他命令或脚本if (pipe == nullptr) {std::cout << "Failed to create child process." << std::endl;return -1;}// 子进程部分char buffer[256];while (!feof(pipe)) {fgets(buffer, sizeof(buffer), pipe);printf("result: %s\n", buffer);}pclose(pipe); // 关闭管道printf("pclose(pipe); : %s\n", buffer);exit(EXIT_SUCCESS);
#endif} else {std::cerr << "Fork failed!" << std::endl;return -1;}return 0;
}

http://www.yayakq.cn/news/876469/

相关文章:

  • 菲律宾网站网站建设南通电子商务网站建设
  • 北京高端网站建设公司浩森宇特网站建设的作用
  • 企业做外贸网站常用术语扬州个人做网站
  • 在哪个网站做旅游攻略好网页设计公司深圳
  • 凡科网站建设步骤有没有做海报的网站推荐
  • 网页设计公司有什么部门外贸网站seo优化方案
  • 网站建设项目合同设计的好网站
  • 做外贸主要是哪些网站258做网站怎么样
  • 服装网站html模板兰州起点网站建设
  • 设计网站的结构时下面哪个方法不好罗湖做网站的公司哪家好
  • ftp怎么上传文件到网站wordpress新建会员主页
  • 重庆做网站建设公司高端网站开发哪家强
  • 做网站建设推荐aspsql server典型网站建设案例 源码
  • 龙岗网站建设公司效果中文商城响应式html网站模板
  • 很多网站开发没有框架如何制作的wordpress ping百度
  • 网站建设服务器什么意思怎么免费建设自己网站
  • 专业做酒店网站智联招聘网站怎么做微招聘
  • 手机与pc的网站开发学校网站建设工作计划
  • 做视频网站要多少钱h5 php mysql网站开发
  • 什么网站可以看到绵阳建设跨境电商公司排名
  • c 网站开发部署品牌型网站建设公司
  • 河北seo网站设计怎么把网站放到服务器上
  • 物流企业网站建设步骤wordpress模板定做
  • 网站建设的价格公众号开通
  • 网站建设后台管理怎么管理张家界市建设网站
  • 想学做网站报班做搜狗网站快速排名软
  • 做网站 收费wordpress邮件设置方法
  • 游标卡尺 东莞网站建设html网页代码完整代码四个跳
  • 软件开发商网站煤矿网站建设
  • 灵璧县建设局网站乐陵关键词seo