如果fork后不进行wait或waitpid,那么子进程将会成会僵尸进程。double fork后, second child成为孤儿进程,由init负责后续的清理工作。
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>| # encoding: utf-8 | |
| import os | |
| import sys | |
| import time | |
| import atexit | |
| from signal import SIGTERM | |
| ''' | |
| A daemon class referred from | |
| `http://www.jejik.com/files/examples/daemon.py` |
| #! /usr/bin/env python | |
| # coding: utf-8 | |
| ''' | |
| auto switch keyboard between different applications | |
| if you want to change the app list, modify the var 'ignore_list' | |
| ''' | |
| from AppKit import NSWorkspace, NSWorkspaceDidActivateApplicationNotification, NSWorkspaceApplicationKey |
| The gist that used to be here has since been implemented as a complete pip-installable package: https://github.com/anqxyr/mkepub | |
| This notice is left here as a courtesy to the people who starred/bookmarked this gist in the past. | |
| from .weixin_compat import fixup_weixin_oauth | |
| oauth = OAuth() | |
| weixin = oauth.remote_app( | |
| 'weixin', | |
| app_key='WEIXIN', | |
| request_token_params={'scope': 'snsapi_base'}, | |
| base_url='https://api.weixin.qq.com', | |
| authorize_url='https://open.weixin.qq.com/connect/oauth2/authorize', | |
| access_token_url='https://api.weixin.qq.com/sns/oauth2/access_token', |