{"id":1127,"date":"2026-10-23T05:00:00","date_gmt":"2026-10-22T20:00:00","guid":{"rendered":"https:\/\/quantumsea.net\/?p=1127"},"modified":"2026-10-22T15:18:42","modified_gmt":"2026-10-22T06:18:42","slug":"qs-linux-dup-shared-file-offset-20261022","status":"publish","type":"post","link":"https:\/\/quantumsea.net\/?p=1127","title":{"rendered":"dup\u3067\u8907\u88fd\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u5b50\u3001\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u306f\u3069\u3053\u3067\u5171\u6709\u3055\u308c\u308b\u304b"},"content":{"rendered":"<p>\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092\u4e8c\u3064\u306e\u51e6\u7406\u3067\u8aad\u3080\u3068\u304d\u3001\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u5b50\u3092\u8907\u88fd\u3059\u308c\u3070\u3001\u305d\u308c\u305e\u308c\u304c\u5148\u982d\u304b\u3089\u8aad\u3081\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002Linux\u306e<code style=\"overflow-wrap:anywhere;\">dup()<\/code>\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3084\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u3092\u4e38\u3054\u3068\u30b3\u30d4\u30fc\u3059\u308b\u64cd\u4f5c\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u5897\u3048\u308b\u306e\u306f\u64cd\u4f5c\u306b\u4f7f\u3046\u756a\u53f7\u3067\u3042\u308a\u3001\u305d\u306e\u5148\u306b\u3042\u308b\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u306f\u5171\u6709\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u9055\u3044\u3092\u77e5\u308b\u3068\u3001\u30ed\u30b0\u306e\u8aad\u307f\u51fa\u3057\u3084\u6a19\u6e96\u51fa\u529b\u306e\u4ed8\u3051\u66ff\u3048\u3067\u300c\u5225\u306e\u756a\u53f7\u306a\u306e\u306b\u4e92\u3044\u306b\u5f71\u97ff\u3059\u308b\u300d\u7406\u7531\u3092\u6574\u7406\u3067\u304d\u307e\u3059\u3002<\/p>\n<section class=\"influvetor-quick-summary\" aria-label=\"\u7c21\u5358\u306b\u307e\u3068\u3081\u308b\u3068\uff1f\">\n<p><strong>\u7c21\u5358\u306b\u307e\u3068\u3081\u308b\u3068\uff1f<\/strong><\/p>\n<ul>\n<li><code style=\"overflow-wrap:anywhere;\">dup()<\/code>\u3067\u5f97\u305f\u4e8c\u3064\u306e\u756a\u53f7\u306f\u3001\u540c\u3058\u300c\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u300d\u3092\u53c2\u7167\u3059\u308b\u305f\u3081\u3001\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u4f4d\u7f6e\u3068\u30d5\u30a1\u30a4\u30eb\u72b6\u614b\u30d5\u30e9\u30b0\u3092\u5171\u6709\u3057\u307e\u3059\u3002<\/li>\n<li>\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092\u5225\u3005\u306b<code style=\"overflow-wrap:anywhere;\">open()<\/code>\u3059\u308c\u3070\u3001\u901a\u5e38\u306f\u4f4d\u7f6e\u3092\u5225\u3005\u306b\u6301\u3066\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u81ea\u4f53\u304c\u5225\u7269\u306b\u306a\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/li>\n<li>\u7279\u5b9a\u306e\u756a\u53f7\u3078\u4ed8\u3051\u66ff\u3048\u308b<code style=\"overflow-wrap:anywhere;\">dup2()<\/code>\u306f\u3001\u9589\u3058\u308b\u64cd\u4f5c\u3068\u518d\u5229\u7528\u3092\u4e0d\u53ef\u5206\u306b\u884c\u3044\u307e\u3059\u3002\u756a\u53f7\u306e\u4ed8\u3051\u66ff\u3048\u306e\u5b89\u5168\u6027\u3068\u3001\u8907\u6570\u306e\u8aad\u307f\u66f8\u304d\u5168\u4f53\u306e\u5b89\u5168\u6027\u306f\u5225\u306e\u554f\u984c\u3067\u3059\u3002<\/li>\n<\/ul>\n<\/section>\n<h2>\u756a\u53f7\u3001\u958b\u3044\u305f\u72b6\u614b\u3001\u30d5\u30a1\u30a4\u30eb\u672c\u4f53\u3092\u5206\u3051\u308b<\/h2>\n<p>\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u5b50\uff08file descriptor\uff09\u306f\u3001\u30d7\u30ed\u30bb\u30b9\u304c\u5165\u51fa\u529b\u306b\u4f7f\u3046\u5c0f\u3055\u306a\u6574\u6570\u3067\u3059\u3002\u6a19\u6e96\u5165\u529b\u306e0\u3001\u6a19\u6e96\u51fa\u529b\u306e1\u3001\u6a19\u6e96\u30a8\u30e9\u30fc\u51fa\u529b\u306e2\u3082\u3053\u306e\u756a\u53f7\u3067\u3059\u3002\u756a\u53f7\u3092\u6307\u5b9a\u3057\u3066<code style=\"overflow-wrap:anywhere;\">read()<\/code>\u3084<code style=\"overflow-wrap:anywhere;\">write()<\/code>\u3092\u547c\u3076\u3068\u3001\u30ab\u30fc\u30cd\u30eb\u5074\u306e\u958b\u3044\u305f\u72b6\u614b\u3092\u901a\u3058\u3066\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u3078\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u958b\u3044\u305f\u72b6\u614b\u304c\u3001\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\uff08open file description\uff09\u3067\u3059\u3002\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u300c\u6b21\u306b\u3069\u306e\u4f4d\u7f6e\u304b\u3089\u8aad\u307f\u66f8\u304d\u3059\u308b\u304b\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u30aa\u30d5\u30bb\u30c3\u30c8\u3084\u3001\u8ffd\u8a18\u30e2\u30fc\u30c9\u306a\u3069\u306e\u30d5\u30a1\u30a4\u30eb\u72b6\u614b\u30d5\u30e9\u30b0\u3092\u4fdd\u6301\u3057\u307e\u3059\u3002\u30c7\u30a3\u30b9\u30af\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u672c\u4f53\u3001\u958b\u3044\u305f\u72b6\u614b\u3001\u30d7\u30ed\u30bb\u30b9\u5185\u306e\u756a\u53f7\u306f\u3001\u540c\u3058\u3082\u306e\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p><code style=\"overflow-wrap:anywhere;\">open()<\/code>\u306f\u65b0\u3057\u3044\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u3092\u4f5c\u308a\u3001\u305d\u308c\u3092\u53c2\u7167\u3059\u308b\u756a\u53f7\u3092\u8fd4\u3057\u307e\u3059\u3002\u4e00\u65b9\u3001<code style=\"overflow-wrap:anywhere;\">dup(oldfd)<\/code>\u306f\u65e2\u5b58\u306e\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u3092\u53c2\u7167\u3059\u308b\u5225\u306e\u756a\u53f7\u3092\u8fd4\u3057\u307e\u3059\u3002\u8fd4\u308b\u306e\u306f\u3001\u305d\u306e\u30d7\u30ed\u30bb\u30b9\u5185\u3067\u4f7f\u308f\u308c\u3066\u3044\u306a\u3044\u6700\u5c0f\u306e\u756a\u53f7\u3067\u3059\u3002\u756a\u53f7\u304c\u4e8c\u3064\u3042\u3063\u3066\u3082\u3001\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u306e\u7f6e\u304d\u5834\u306f\u4e00\u3064\u3001\u3068\u3044\u3046\u95a2\u4fc2\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u4e8c\u3064\u306e\u8aad\u307f\u53d6\u308a\u304c\u4e00\u3064\u306e\u4f4d\u7f6e\u3092\u9032\u3081\u308b<\/h2>\n<p>\u5177\u4f53\u4f8b\u3068\u3057\u3066\u3001\u5185\u5bb9\u304c<code style=\"overflow-wrap:anywhere;\">ABCDEFGH<\/code>\u306e8\u30d0\u30a4\u30c8\u306e\u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u3092\u8003\u3048\u307e\u3059\u3002A\u3067\u958b\u3044\u305f\u76f4\u5f8c\u306b<code style=\"overflow-wrap:anywhere;\">dup()<\/code>\u3067B\u3092\u4f5c\u308a\u3001A\u304b\u30893\u30d0\u30a4\u30c8\u3001\u7d9a\u3051\u3066B\u304b\u30892\u30d0\u30a4\u30c8\u3092\u8aad\u307f\u307e\u3059\u3002\u5404\u547c\u3073\u51fa\u3057\u304c\u6307\u5b9a\u30d0\u30a4\u30c8\u6570\u3092\u6b63\u5e38\u306b\u8aad\u307f\u3001\u9014\u4e2d\u3067\u307b\u304b\u306e\u8aad\u307f\u66f8\u304d\u3084\u4f4d\u7f6e\u5909\u66f4\u304c\u306a\u3044\u5834\u5408\u3001A\u306f<code style=\"overflow-wrap:anywhere;\">ABC<\/code>\u3001B\u306f<code style=\"overflow-wrap:anywhere;\">DE<\/code>\u3092\u8fd4\u3057\u307e\u3059\u3002B\u304c<code style=\"overflow-wrap:anywhere;\">AB<\/code>\u3092\u8fd4\u3055\u306a\u3044\u306e\u306f\u3001A\u304c\u5171\u6709\u306e\u4f4d\u7f6e\u30920\u304b\u30893\u3078\u9032\u3081\u305f\u304b\u3089\u3067\u3059\u3002\u6700\u5f8c\u306e\u5171\u6709\u4f4d\u7f6e\u306f5\u3067\u3059\u3002<\/p>\n<figure style=\"margin:24px 0;max-width:100%;\"><img decoding=\"async\" src=\"https:\/\/quantumsea.net\/wp-content\/uploads\/2026\/10\/qs-linux-dup-shared-file-offset-20261022-figure-a8fadc07605e.png\" alt=\"dup\u306e\u4f8b\u3067\u306fA\u306e3\u30d0\u30a4\u30c8\u8aad\u53d6\u308a\u5f8c\u306bB\u304cDE\u3092\u8aad\u307f\u5171\u6709\u4f4d\u7f6e\u306f5\u306b\u306a\u308b\u3002\u5225\u3005\u306eopen\u3067\u306fA\u304cABC\u3001B\u304cAB\u3092\u8aad\u307f\u4f4d\u7f6e\u306f3\u30682\u306b\u5206\u304b\u308c\u308b\u3002\" style=\"display:block;width:100%;max-width:100%;height:auto;\"\/><figcaption>\u540c\u30588\u30d0\u30a4\u30c8\u306e\u5185\u5bb9\u306b\u5bfe\u3059\u308b\u9806\u756a\u3069\u304a\u308a\u306e\u8aad\u307f\u53d6\u308a\u4f8b\u3002\u77ed\u3044\u8aad\u307f\u53d6\u308a\u3001\u5272\u8fbc\u307f\u3001\u307b\u304b\u306e\u51e6\u7406\u306b\u3088\u308b\u5909\u66f4\u306f\u542b\u3081\u306a\u3044\u8aac\u660e\u30e2\u30c7\u30eb\u3002<\/figcaption><\/figure>\n<p>\u3053\u308c\u306b\u5bfe\u3057\u3001\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092A\u3068B\u3067\u5225\u3005\u306b<code style=\"overflow-wrap:anywhere;\">open()<\/code>\u3059\u308b\u3068\u3001\u4e8c\u3064\u306e\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u304c\u3067\u304d\u307e\u3059\u3002\u540c\u3058\u9806\u3067\u8aad\u3080\u3068\u3001A\u306f<code style=\"overflow-wrap:anywhere;\">ABC<\/code>\u3001B\u306f<code style=\"overflow-wrap:anywhere;\">AB<\/code>\u3068\u306a\u308a\u3001\u4f4d\u7f6e\u306f\u305d\u308c\u305e\u308c3\u30682\u3067\u3059\u3002\u7247\u65b9\u304c\u5148\u3092\u8aad\u3093\u3067\u3082\u3001\u3082\u3046\u7247\u65b9\u306e\u4f4d\u7f6e\u306f\u305d\u308c\u3060\u3051\u3067\u306f\u9032\u307f\u307e\u305b\u3093\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001\u8aad\u307f\u51fa\u3057\u51e6\u7406\u3054\u3068\u306b\u72ec\u7acb\u3057\u305f\u4f4d\u7f6e\u304c\u5fc5\u8981\u306a\u3089\u3001\u5358\u306b\u756a\u53f7\u3092\u8907\u88fd\u3059\u308b\u3060\u3051\u3067\u306f\u8db3\u308a\u307e\u305b\u3093\u3002\u5225\u3005\u306b\u958b\u304f\u8a2d\u8a08\u306a\u3069\u3092\u691c\u8a0e\u3057\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u3053\u308c\u306f\u30c7\u30fc\u30bf\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u308b\u8a71\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u304c\u66f8\u304d\u63db\u3048\u3089\u308c\u308c\u3070\u3001\u305d\u306e\u5185\u5bb9\u306e\u5909\u5316\u306f\u72ec\u7acb\u3057\u305f\u4f4d\u7f6e\u306e\u554f\u984c\u3068\u306f\u5225\u306b\u6271\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5171\u6709\u3059\u308b\u30d5\u30e9\u30b0\u3068\u3001\u756a\u53f7\u3054\u3068\u306e\u30d5\u30e9\u30b0<\/h2>\n<p>\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u3068\u540c\u69d8\u306b\u3001\u30d5\u30a1\u30a4\u30eb\u72b6\u614b\u30d5\u30e9\u30b0\u3082\u30aa\u30fc\u30d7\u30f3\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u306b\u5c5e\u3057\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u8ffd\u8a18\u3092\u6307\u5b9a\u3059\u308b<code style=\"overflow-wrap:anywhere;\">O_APPEND<\/code>\u306a\u3069\u3067\u3059\u3002\u8907\u88fd\u3057\u305f\u7247\u65b9\u3092\u901a\u3057\u3066\u5171\u6709\u306e\u72b6\u614b\u3092\u5909\u66f4\u3059\u308c\u3070\u3001\u3082\u3046\u7247\u65b9\u306b\u3082\u5f71\u97ff\u3057\u307e\u3059\u3002\u72ec\u7acb\u3057\u305f\u756a\u53f7\u3060\u304b\u3089\u8a2d\u5b9a\u3082\u72ec\u7acb\u3060\u3001\u3068\u8003\u3048\u306a\u3044\u3053\u3068\u304c\u5927\u5207\u3067\u3059\u3002<\/p>\n<p>\u4e00\u65b9\u3001\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u5b50\u30d5\u30e9\u30b0\u306f\u756a\u53f7\u3054\u3068\u306e\u5c5e\u6027\u3067\u3059\u3002\u4ee3\u8868\u304c<code style=\"overflow-wrap:anywhere;\">FD_CLOEXEC<\/code>\u3067\u3001\u65b0\u3057\u3044\u30d7\u30ed\u30b0\u30e9\u30e0\u3078\u7f6e\u304d\u63db\u3048\u308bexec\u7cfb\u64cd\u4f5c\u306e\u969b\u306b\u3001\u305d\u306e\u756a\u53f7\u3092\u9589\u3058\u308b\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002Linux\u306e<code style=\"overflow-wrap:anywhere;\">dup()<\/code>\u3067\u65b0\u3057\u304f\u5f97\u305f\u756a\u53f7\u3067\u306f\u3001\u3053\u306e\u30d5\u30e9\u30b0\u306f\u89e3\u9664\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u5143\u306e\u756a\u53f7\u306e\u30d5\u30e9\u30b0\u304c\u3001\u305d\u306e\u307e\u307e\u5f15\u304d\u7d99\u304c\u308c\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u8907\u88fd\u3068\u540c\u6642\u306bclose-on-exec\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u3001Linux\u3067\u306f<code style=\"overflow-wrap:anywhere;\">dup3(oldfd, newfd, O_CLOEXEC)<\/code>\u3068\u3044\u3046\u9078\u629e\u80a2\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306fC\u306e\u30b7\u30b9\u30c6\u30e0\u30b3\u30fc\u30eb\u306e\u4ed5\u69d8\u306b\u3064\u3044\u3066\u306e\u8aac\u660e\u3067\u3059\u3002\u5225\u8a00\u8a9e\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5b89\u5168\u6027\u306e\u305f\u3081\u306b\u7d99\u627f\u8a2d\u5b9a\u3092\u5909\u3048\u3066\u3044\u308b\u5834\u5408\u3082\u3042\u308b\u306e\u3067\u3001\u305d\u306e\u30e9\u30c3\u30d1\u30fc\u306e\u4ed5\u69d8\u306f\u5206\u3051\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<h2>\u6a19\u6e96\u51fa\u529b\u3092\u4ed8\u3051\u66ff\u3048\u308b\u3068\u304d\u3001\u306a\u305cdup2\u3092\u4f7f\u3046\u306e\u304b<\/h2>\n<p><code style=\"overflow-wrap:anywhere;\">dup2(oldfd, newfd)<\/code>\u306f\u3001\u8907\u88fd\u5148\u306e\u756a\u53f7\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u3001\u3059\u3067\u306b\u958b\u3044\u3066\u3042\u308b\u51fa\u529b\u5148\u3092\u756a\u53f71\u3078\u5272\u308a\u5f53\u3066\u308c\u3070\u3001\u305d\u306e\u5f8c\u306e\u6a19\u6e96\u51fa\u529b\u3092\u305d\u306e\u958b\u3044\u305f\u72b6\u614b\u3078\u5411\u3051\u3089\u308c\u307e\u3059\u3002\u65e2\u5b58\u306e<code style=\"overflow-wrap:anywhere;\">newfd<\/code>\u304c\u958b\u3044\u3066\u3044\u308c\u3070\u3001\u305d\u308c\u3092\u9589\u3058\u3066\u756a\u53f7\u3092\u518d\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3092<code style=\"overflow-wrap:anywhere;\">close(newfd)<\/code>\u3068<code style=\"overflow-wrap:anywhere;\">dup(oldfd)<\/code>\u306e\u4e8c\u6bb5\u968e\u306b\u5206\u3051\u308b\u3068\u3001\u9593\u306b\u5225\u306e\u30b9\u30ec\u30c3\u30c9\u3084\u30b7\u30b0\u30ca\u30eb\u30cf\u30f3\u30c9\u30e9\u30fc\u304c\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u3001\u7a7a\u3044\u305f\u756a\u53f7\u3092\u5148\u306b\u4f7f\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<code style=\"overflow-wrap:anywhere;\">dup2()<\/code>\u306f\u3001\u9589\u3058\u308b\u64cd\u4f5c\u3068\u305d\u306e\u756a\u53f7\u306e\u518d\u5229\u7528\u3092\u4e0d\u53ef\u5206\u306b\u884c\u3046\u3053\u3068\u3067\u3001\u3053\u306e\u9699\u9593\u3092\u306a\u304f\u3057\u307e\u3059\u3002\u300c\u4e0d\u53ef\u5206\u300d\u3068\u3044\u3046\u4fdd\u8a3c\u306e\u5bfe\u8c61\u306f\u3053\u306e\u4ed8\u3051\u66ff\u3048\u3067\u3042\u308a\u3001\u4e00\u9023\u306e\u696d\u52d9\u51e6\u7406\u3084\u8907\u6570\u56de\u306e\u8aad\u307f\u66f8\u304d\u3092\u307e\u3068\u3081\u3066\u4fdd\u8b77\u3059\u308b\u4fdd\u8a3c\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u7d30\u90e8\u306b\u3082\u9055\u3044\u304c\u3042\u308a\u307e\u3059\u3002\u6709\u52b9\u306a<code style=\"overflow-wrap:anywhere;\">oldfd<\/code>\u3068<code style=\"overflow-wrap:anywhere;\">newfd<\/code>\u304c\u540c\u3058\u306a\u3089\u3001<code style=\"overflow-wrap:anywhere;\">dup2()<\/code>\u306f\u4f55\u3082\u305b\u305a\u305d\u306e\u756a\u53f7\u3092\u8fd4\u3057\u307e\u3059\u3002<code style=\"overflow-wrap:anywhere;\">dup3()<\/code>\u3067\u306f\u540c\u3058\u756a\u53f7\u306e\u6307\u5b9a\u306f\u30a8\u30e9\u30fc\u3067\u3059\u3002\u307e\u305f<code style=\"overflow-wrap:anywhere;\">dup2()<\/code>\u3067\u5143\u306e\u756a\u53f7\u304c\u7121\u52b9\u306a\u3089\u3001\u8907\u88fd\u5148\u306f\u9589\u3058\u3089\u308c\u307e\u305b\u3093\u3002\u5931\u6557\u3092\u300c\u3082\u3046\u9589\u3058\u3089\u308c\u305f\u306f\u305a\u300d\u3068\u6c7a\u3081\u3064\u3051\u305a\u3001\u623b\u308a\u5024\u3068\u30a8\u30e9\u30fc\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u7528\u9014\u306b\u5408\u308f\u305b\u3066\u78ba\u8a8d\u3059\u308b\u4e09\u3064\u306e\u70b9<\/h2>\n<p>\u9078\u3073\u65b9\u306f\u3001\u4f55\u3092\u5171\u6709\u3057\u305f\u3044\u304b\u304b\u3089\u8003\u3048\u3089\u308c\u307e\u3059\u3002\u7b2c\u4e00\u306b\u3001\u540c\u3058\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u3092\u4f7f\u3046\u306e\u304b\u3001\u5225\u3005\u306b\u9032\u307f\u305f\u3044\u306e\u304b\u3002\u7b2c\u4e8c\u306b\u3001\u8ffd\u8a18\u306a\u3069\u306e\u72b6\u614b\u30d5\u30e9\u30b0\u3092\u5171\u6709\u3057\u3066\u3088\u3044\u306e\u304b\u3002\u7b2c\u4e09\u306b\u3001\u756a\u53f7\u3092\u6307\u5b9a\u3057\u3066\u4ed8\u3051\u66ff\u3048\u308b\u5fc5\u8981\u3068\u3001exec\u6642\u306b\u756a\u53f7\u3092\u6b8b\u3059\u5fc5\u8981\u304c\u3042\u308b\u306e\u304b\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4f8b\u306f\u3001\u4f4d\u7f6e\u3092\u6301\u3064\u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u3059\u308b\u9010\u6b21\u51e6\u7406\u3067\u3059\u3002\u30d1\u30a4\u30d7\u3084\u30bd\u30b1\u30c3\u30c8\u3092\u540c\u3058\u300c\u30d5\u30a1\u30a4\u30eb\u306e\u4f55\u30d0\u30a4\u30c8\u76ee\u300d\u3068\u3044\u3046\u56f3\u3067\u6271\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u307e\u305f\u3001\u5b9f\u969b\u306e<code style=\"overflow-wrap:anywhere;\">read()<\/code>\u306f\u5e38\u306b\u8981\u6c42\u3057\u305f\u91cf\u3092\u8fd4\u3059\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002\u5171\u6709\u69cb\u9020\u306e\u7406\u89e3\u3068\u3001\u77ed\u3044\u8aad\u307f\u53d6\u308a\u30fb\u30a8\u30e9\u30fc\u30fb\u4e26\u884c\u51e6\u7406\u3078\u306e\u5bfe\u51e6\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u306f\u3058\u3081\u3066\u3001\u5b9f\u88c5\u306e\u5224\u65ad\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/p>\n<h2>\u51fa\u5178\u30fb\u53c2\u8003\u8cc7\u6599<\/h2>\n<ul>\n<li><a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/dup.2.html\">Linux man-pages 6.19 \u2014 dup(2)<\/a>\uff1a\u8907\u88fd\u5f8c\u306e\u5171\u6709\u3001dup2\/dup3\u306e\u5dee\u3001\u4e0d\u53ef\u5206\u306a\u756a\u53f7\u306e\u518d\u5229\u7528\u3002\u53c2\u7167\u72482026\u5e742\u67088\u65e5\u3002<\/li>\n<li><a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/open.2.html\">Linux man-pages 6.19 \u2014 open(2)<\/a>\uff1aDESCRIPTION\u3001NOTES\u306eOpen file descriptions\u3001O_CLOEXEC\u3002\u63b2\u8f09HTML\u30922026\u5e7410\u670822\u65e5\u306b\u78ba\u8a8d\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092\u4e8c\u3064\u306e\u51e6\u7406\u3067\u8aad\u3080\u3068\u304d\u3001\u30d5\u30a1\u30a4\u30eb\u8a18\u8ff0\u5b50\u3092\u8907\u88fd\u3059\u308c\u3070\u3001\u305d\u308c\u305e\u308c\u304c\u5148\u982d\u304b\u3089\u8aad\u3081\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002Linux\u306edup()\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3084\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u3092\u4e38\u3054\u3068\u30b3\u30d4\u30fc\u3059\u308b\u64cd\u4f5c\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u5897\u3048\u308b\u306e\u306f\u64cd\u4f5c\u306b\u4f7f\u3046\u756a\u53f7\u3067 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":1125,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[30],"tags":[244],"class_list":["post-1127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computing","tag-linux"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/quantumsea.net\/wp-content\/uploads\/2026\/10\/qs-linux-dup-shared-file-offset-20261022-featured-3e64930e9782.png","_links":{"self":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1127"}],"version-history":[{"count":1,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1127\/revisions"}],"predecessor-version":[{"id":1128,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1127\/revisions\/1128"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/media\/1125"}],"wp:attachment":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}