zoukankan      html  css  js  c++  java
  • 我对bgwriter.c 与 guc 关系的初步理解

    我用例子来说明:只是一个模拟,我自己做的 假的 bgwriter.c

    [root@localhost test]# cat bgwriter.c
    #include<stdio.h>
    #include<stdlib.h>
    #include<signal.h>
    #include "bgwriter.h"
    #include "guc.h"
    //some conditions make it change, eg:signal
    int BgWriterDelay=100;
    void sighandler(int sig);
    int main()
    {
     
      signal(SIGHUP,sighandler);
      for (;;)
      {
        sleep(1);
      }
    }
    void sighandler(int sig)
    {
      changeDelay();
      fprintf(stderr,"BgWriterDelay is now %d.\n",BgWriterDelay);
      //here I just want to demo, so close it
      exit(0);
    }
    [root@localhost test]#
    /////////////////////////////////////////////////////////////////
    下面的 "bgwriter.h" and "guc.h" and "guc.c",也都是假的。只是为了模拟。
    ///////////////////////////////////////////////////////////////// [root@localhost test]# cat bgwriter.h extern int BgWriterDelay; [root@localhost test]# [root@localhost test]# cat guc.h extern void changeDelay(); [root@localhost test]#cat guc.c #include "bgwriter.h" void changeDelay() { //to simulate reading configuration file etc. BgWriterDelay=500; } [root@localhost test]# ///////////////////////////////////////////////////////////////// 给 SIGHUP 信号 [root@localhost test]# gcc bgwriter.c guc.c -o bgwriter.o [root@localhost test]# ./bgwriter.o [root@localhost ~]# ps -ef|grep bgwriter.o root 5475 5297 0 15:08 pts/6 00:00:00 ./bgwriter.o root 5500 5479 0 15:08 pts/7 00:00:00 grep bgwriter.o [root@localhost ~]# kill -s SIGHUP 5475 [root@localhost ~]# BgWriterDelay is now 500. [root@localhost test]#

    结束:

  • 相关阅读:
    iOS 简单获取当前地理坐标
    iOS 企业账号申请证书和打包ipa
    iOS 代码片段的添加!
    iOS 扩展类方法之category!
    iOS 数组和字典排序
    iOS 字符串NSString 的一些常用方法
    iOS 一些常见问题
    iOS 数据库sqlite完整增删改查操作
    iOS pch文件的创建
    iOS 通过网络请求获取图片的下载歌曲
  • 原文地址:https://www.cnblogs.com/gaojian/p/2747388.html
Copyright © 2011-2022 走看看