{"id":20231010,"url":"https://github.com/bewaremypower/ipc_learning","last_synced_at":"2025-09-04T19:41:21.107Z","repository":{"id":109020235,"uuid":"138580651","full_name":"BewareMyPower/ipc_learning","owner":"BewareMyPower","description":"IPC机制学习","archived":false,"fork":false,"pushed_at":"2018-10-11T12:39:56.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T13:45:39.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BewareMyPower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-25T10:37:58.000Z","updated_at":"2021-11-18T13:02:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"2eb1a56a-b0cb-49a9-b277-21ed54355b6d","html_url":"https://github.com/BewareMyPower/ipc_learning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BewareMyPower/ipc_learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fipc_learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fipc_learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fipc_learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fipc_learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BewareMyPower","download_url":"https://codeload.github.com/BewareMyPower/ipc_learning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fipc_learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273664782,"owners_count":25146270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:44:50.913Z","updated_at":"2025-09-04T19:41:21.051Z","avatar_url":"https://github.com/BewareMyPower.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ipc_learning\n实践进程间通信(IPC)的代码，主要参考*The Linux Programming Interface*(简称`TLPI`)的示例代码，使用自定义的简易错误处理库。\n# 自定义编码风格\n1. 命名风格\n类命名采用大驼峰命名法，比如`MyData`;\n函数命名采用驼峰命名法，比如`getName()`;\n变量命名采用帕斯卡命名法，比如`my_data`;\n宏/常量均采用大写字母和下划线集合的形式，比如`BUFFER_SIZE`;\n不严格禁止缩写，比如`fd`代表`file descriptor`，`epfd`代表`epoll file descriptor`，但是像`num_read`这种并未缩写。\n2. 大括号\n左括号放在语句行末，右括号根据块内内容决定是否换行，若在同一行，需要和语句用空格隔开\n```\nvoid func() { printf(\"hello\\n\"); }\nvoid func(int i, double d, const char* s) {\n    printf(\"%d %f %s\\n\", i, d, s);\n}\n```\n3. 缩进采用4个空格，双目运算符左右均留出一个空格。\n4. 关于goto语句，仅在处理信号时使用goto语句。\n5. 对于简单变量的检查，把if语句和xxxExit语句放在同一行；对于包含函数调用的条件语句，把if语句和xxxExit语句放在两行。\n```\nif (ret == -1) errorExit(\"func\");\nif (doSystemCall() == -1)\n    errorSystemCall(errno, \"doSystemCall\");\n```\n\n# 简易错误处理库([error_handler.hpp](include/error_handler.hpp))\n- `errorMsg(const char*, ...)`：相当于`fprintf`打印参数内容后再打印换行符；\n- `errorMsg(error, const char*, ...)：在打印换行符之前打印`\": *errormsg*\"`，*erromsg*是错误码`error`对应的信息；\n- `errorExit(...)`：将参数传入`errorMsg`打印信息后，`exit(1)`终止程序。\n\n最开始考虑过`errorExitIf(bool, ...)`这种API，但发现挤在一行会使代码变得难以阅读，于是放弃之，若用户想自定义这样的API，可以简单地用下述宏定义的方式\n```\n#define errorExitIf(b, ...) if (b) { errorExit(__VA_ARGS__); }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fipc_learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbewaremypower%2Fipc_learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fipc_learning/lists"}