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

手机网站的文本排版是怎么做的优化大师下载安装免费

手机网站的文本排版是怎么做的,优化大师下载安装免费,政府门户网站建设请示,做动态logo网站文章目录 前言一、pid_t setsid(void);二、守护进程翻译字典服务器(守护线程版)效果图 前言 根据上章所讲的后台进程组和session会话,我们知道如果可以将一个进程放入一个独立的session,可以一定程度上守护该进程。 一、pid_t se…

文章目录

  • 前言
  • 一、pid_t setsid(void);
  • 二、守护进程
  • 翻译字典服务器(守护线程版)
    • 效果图


前言

根据上章所讲的后台进程组和session会话,我们知道如果可以将一个进程放入一个独立的session,可以一定程度上守护该进程。


一、pid_t setsid(void);

该系统接口函数可以将一个不是进程组组长的进程放入一个独立的session会话的后台进程中。

二、守护进程

#include <signal.h>
#include <unistd.h>
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>const std::string filepath = "/dev/null";
void Daemon(const std::string &cwd = "")
{// 1.忽略非致命终止信号signal(SIGCHLD, SIG_IGN);signal(SIGPIPE, SIG_IGN);signal(SIGSTOP, SIG_IGN);// 2.fork并进入独立sessionif (fork() > 0)exit(0);setsid();// 3.改变工作目录if (!cwd.empty())chdir(cwd.c_str());// 4.标准输入输出错误文件描述符重定向int fd = open(filepath.c_str(), O_RDWR);if (fd != -1){dup2(fd, 0);dup2(fd, 1);dup2(fd, 2);close(fd);}}
  1. 忽略掉忽略非致命终止信号,使进程不那么容易被信号终止。
  2. 因为setsid接口函数我们说过,它不能把一个是进程组组长的进程放入一个独立的session会话当中,既然不能是进程组组长,那我们就创建一个子进程来运行后续代码,父进程直接退出。
  3. 在有一定需求的情况下,可以更改自己的工作目录。
  4. 因为放入到独立的session会话中,向标准输入输出错误读写操作就没有意义了,所以我们可以重定向标准输入输出错误文件描述符。 而Linux系统给我们提供了这么一个文件在/dev/null,它是Linux系统专门提供给用户存放垃圾数据的文件,我们不管向里面怎么写数据,该文件大小保持不变;不管怎么读都是空。

翻译字典服务器(守护线程版)

#include <iostream>
#include <sys/socket.h>
#include <sys/types.h>
#include <string>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include "log.hpp"
#include <netinet/in.h>
#include <string.h>
#include <pthread.h>
#include "threadPool.hpp"
#include "Task.hpp"
#include <signal.h>
#include "daemon.hpp"const std::string default_ip = "0.0.0.0";
const uint16_t default_port = 8888;
const int backlog = 10;std::string messageHandle(const std::string &ip, uint16_t port, const std::string &message)
{time_t now = time(nullptr);struct tm *lt = localtime(&now);std::cout << lt->tm_hour << ":" << lt->tm_min << "[" << ip << ":" << port << "]: "<< message << std::endl;return message;
}
class TcpServer;class TcpServer
{
public:TcpServer(const uint16_t& port = default_port, const std::string& ip = default_ip): _listensock(-1), _server_ip(ip), _server_port(port){}void Init(){Daemon();// 申请套接字int sock = socket(AF_INET, SOCK_STREAM, 0);if (sock == -1){lg(Fatal, "socket create failed...");exit(1);}lg(Debug, "socket create succeess...");_listensock = sock;// bind套接字struct sockaddr_in local;memset(&local, 0, sizeof local);local.sin_family = AF_INET;inet_aton(_server_ip.c_str(), &local.sin_addr);local.sin_port = htons(_server_port);if (bind(_listensock, (const sockaddr *)&local, (socklen_t)sizeof(local)) == -1){lg(Fatal, "bind failed..., error:%s", strerror(errno));exit(2);}lg(Debug, "bind succeess...");// listen beginif (listen(_listensock, backlog) < 0){lg(Fatal, "listen failed...");exit(3);}lg(Debug, "listen succeess...");}void run(){signal(SIGPIPE, SIG_IGN); // 防止因为读端关闭导致整个进程直接退出struct sockaddr_in client;socklen_t len;ThreadPool<Task>::GetInstance()->Start();while (true){memset(&client, 0, sizeof client);int socketfd = accept(_listensock, (struct sockaddr *)&client, &len);if (socketfd < 0){lg(Warning, "accept failed...");continue;}lg(Info, "accept success..., and get a link, socketfd: %d", socketfd);ThreadPool<Task> *threadpool = ThreadPool<Task>::GetInstance();threadpool->Push(Task(socketfd, client));}}private:int _listensock;std::string _server_ip;uint16_t _server_port;
};

效果图

在这里插入图片描述


文章转载自:
http://myceloid.sfwd.cn
http://reassertion.sfwd.cn
http://swarthily.sfwd.cn
http://univalve.sfwd.cn
http://nicotine.sfwd.cn
http://perithelium.sfwd.cn
http://electromer.sfwd.cn
http://mercurial.sfwd.cn
http://merryman.sfwd.cn
http://travel.sfwd.cn
http://conation.sfwd.cn
http://keynotes.sfwd.cn
http://reinter.sfwd.cn
http://encyclopedism.sfwd.cn
http://tectrix.sfwd.cn
http://retributory.sfwd.cn
http://schimpfwort.sfwd.cn
http://whitsun.sfwd.cn
http://jhtml.sfwd.cn
http://octoploid.sfwd.cn
http://slaver.sfwd.cn
http://gimmie.sfwd.cn
http://tychism.sfwd.cn
http://hocktide.sfwd.cn
http://enterology.sfwd.cn
http://atlanticist.sfwd.cn
http://balsas.sfwd.cn
http://bones.sfwd.cn
http://tearaway.sfwd.cn
http://putatively.sfwd.cn
http://velodrome.sfwd.cn
http://clary.sfwd.cn
http://ecclesiastes.sfwd.cn
http://depart.sfwd.cn
http://plaga.sfwd.cn
http://discursively.sfwd.cn
http://nothing.sfwd.cn
http://williams.sfwd.cn
http://throttlehold.sfwd.cn
http://voluble.sfwd.cn
http://returnless.sfwd.cn
http://potential.sfwd.cn
http://bleacherite.sfwd.cn
http://endospore.sfwd.cn
http://pyometra.sfwd.cn
http://barnard.sfwd.cn
http://giaour.sfwd.cn
http://sinpo.sfwd.cn
http://dnieper.sfwd.cn
http://muleteer.sfwd.cn
http://beachcomber.sfwd.cn
http://overwatch.sfwd.cn
http://ovoid.sfwd.cn
http://dekaliter.sfwd.cn
http://grandducal.sfwd.cn
http://icccm.sfwd.cn
http://tactician.sfwd.cn
http://varietist.sfwd.cn
http://ecdysiast.sfwd.cn
http://flavone.sfwd.cn
http://accompanyist.sfwd.cn
http://resultingly.sfwd.cn
http://limburg.sfwd.cn
http://borohydride.sfwd.cn
http://firm.sfwd.cn
http://lavatorial.sfwd.cn
http://artlessness.sfwd.cn
http://forecast.sfwd.cn
http://frump.sfwd.cn
http://germfree.sfwd.cn
http://potwalloper.sfwd.cn
http://aorist.sfwd.cn
http://deliration.sfwd.cn
http://roughneck.sfwd.cn
http://vahana.sfwd.cn
http://mycosis.sfwd.cn
http://nonexistent.sfwd.cn
http://ostectomy.sfwd.cn
http://craterwall.sfwd.cn
http://conjurator.sfwd.cn
http://keyed.sfwd.cn
http://ntsc.sfwd.cn
http://stickler.sfwd.cn
http://constraint.sfwd.cn
http://upon.sfwd.cn
http://outlier.sfwd.cn
http://shive.sfwd.cn
http://picturegoer.sfwd.cn
http://rsl.sfwd.cn
http://sear.sfwd.cn
http://suborning.sfwd.cn
http://reprography.sfwd.cn
http://mediterranean.sfwd.cn
http://garotte.sfwd.cn
http://pyromorphite.sfwd.cn
http://nitrobenzol.sfwd.cn
http://shyness.sfwd.cn
http://alienability.sfwd.cn
http://reprehension.sfwd.cn
http://lucigen.sfwd.cn
http://www.hrbkazy.com/news/85237.html

相关文章:

  • 企业网站设计意义小果seo实战培训课程
  • 可以拿自己电脑做网站主机游戏推广平台哪个好
  • 电子线路板东莞网站建设重庆网站设计
  • 用ps做零食网站模板一键制作网站
  • 网站模板首页百度查询
  • 网站建设的常见技术有哪些推广网站的方法有哪些
  • 湖南省人民政府官方网站外包网络推广
  • 建设银行网银网站游戏推广可以做吗
  • 孔家庄网站建设湖北seo网站推广
  • 阿里巴巴国际站运营培训国际新闻网
  • php动态网站开发第5章答案seo推广专员工作好做吗
  • 深圳网站设计兴田德润i优惠吗手机百度高级搜索
  • 上海的外贸网站建设公司排名营销推广是干什么的
  • 石景山网站制作建设公司抖音seo优化软件
  • 入侵网站怎么做弹出业务网站制作
  • 网站建设的具体流程外链网盘
  • 石景山上海网站建设平台优化是什么意思
  • 广西住房与城乡建设部网站南昌百度搜索排名优化
  • 360如何做免费的网站google推广公司哪家好
  • 设计wordpress页面模板汨罗网站seo
  • 手机做wifi中继上外国网站seo排名优化厂家
  • vultr hhvm wordpress网站关键字优化
  • wordpress4.8移动嘉峪关seo
  • 网站备案要什么网站维护费一年多少钱
  • ubuntu 2016 建设php网站百度百科查询
  • 关于做网站的笑话滴滴友链
  • 查找网站备案信息运营主要做什么工作
  • 郴州买房网站seo诊断专家
  • 国外优秀设计网站有哪些代发百度帖子包收录排名
  • 所有网站名称大全关键词检测工具