Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1752654267, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"a671c2f55acd495faaaa50f6a2396da8", "commit": {"type":"commit", "time": 1587273326, "time_ofs": 60, "oid_tree": { "oid": "2dcfc2508f647748a8fde515f37dffcea06ea2c1", "alias": []}, "oid":{ "oid": "7399f82959e2fa20629e6982088b59786d800c1a", "alias": []}, "msg": "spawn: CLOEXEC the wsi fds earlier", "sig_commit": { "git_time": { "time": 1587273326, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1587273302, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "spawn: CLOEXEC the wsi fds earlier" , "diff": "diff --git a/lib/plat/unix/unix-spawn.c b/lib/plat/unix/unix-spawn.c\nindex fdc61cd..cbfc11d 100644\n--- a/lib/plat/unix/unix-spawn.c\n+++ b/lib/plat/unix/unix-spawn.c\n@@ -329,13 +329,14 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)\n \t\tlsp-\u003estdwsi[n]-\u003eopaque_user_data \u003d i-\u003eopaque;\n \n \t\tlwsl_debug(\u0022%s: lsp stdwsi %p: pipe idx %d -\u003e fd %d / %d\u005cn\u0022, __func__,\n-\t\t\t lsp-\u003estdwsi[n], n, lsp-\u003epipe_fds[n][!!(n \u003d\u003d 0)],\n-\t\t\t lsp-\u003epipe_fds[n][!(n \u003d\u003d 0)]);\n+\t\t\t lsp-\u003estdwsi[n], n, lsp-\u003epipe_fds[n][n \u003d\u003d 0],\n+\t\t\t lsp-\u003epipe_fds[n][n !\u003d 0]);\n \n \t\t/* read side is 0, stdin we want the write side, others read */\n \n-\t\tlsp-\u003estdwsi[n]-\u003edesc.sockfd \u003d lsp-\u003epipe_fds[n][!!(n \u003d\u003d 0)];\n-\t\tif (fcntl(lsp-\u003epipe_fds[n][!!(n \u003d\u003d 0)], F_SETFL, O_NONBLOCK) \u003c 0) {\n+\t\tlws_plat_apply_FD_CLOEXEC(lsp-\u003epipe_fds[n][n \u003d\u003d 0]);\n+\t\tlsp-\u003estdwsi[n]-\u003edesc.sockfd \u003d lsp-\u003epipe_fds[n][n \u003d\u003d 0];\n+\t\tif (fcntl(lsp-\u003epipe_fds[n][n \u003d\u003d 0], F_SETFL, O_NONBLOCK) \u003c 0) {\n \t\t\tlwsl_err(\u0022%s: setting NONBLOCK failed\u005cn\u0022, __func__);\n \t\t\tgoto bail2;\n \t\t}\n@@ -389,27 +390,27 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)\n \n \tif (lsp-\u003echild_pid) {\n \n-\t\t/* we are the parent process */\n-\n-\t\tlwsl_info(\u0022%s: lsp %p spawned PID %d\u005cn\u0022, __func__, lsp,\n-\t\t\t lsp-\u003echild_pid);\n-\n-\t\tlws_sul_schedule(context, i-\u003etsi, \u0026lsp-\u003esul, lws_spawn_timeout,\n-\t\t\t\t i-\u003etimeout_us ? i-\u003etimeout_us :\n-\t\t\t\t\t\t 300 * LWS_US_PER_SEC);\n-\n \t\t/*\n+\t\t * We are the parent process\n+\t\t *\n \t\t * close: stdin:r, stdout:w, stderr:w\n \t\t * hide from other forks: stdin:w, stdout:r, stderr:r\n \t\t */\n \t\tfor (n \u003d 0; n \u003c 3; n++) {\n-\t\t\tlws_plat_apply_FD_CLOEXEC(lsp-\u003epipe_fds[n][!!(n \u003d\u003d 0)]);\n-\t\t\tclose(lsp-\u003epipe_fds[n][!(n \u003d\u003d 0)]);\n+\t\t\t/* these guys don't have any wsi footprint */\n+\t\t\tclose(lsp-\u003epipe_fds[n][n !\u003d 0]);\n \t\t}\n \n \t\tlsp-\u003epipes_alive \u003d 3;\n \t\tlsp-\u003ecreated \u003d lws_now_usecs();\n \n+\t\tlwsl_info(\u0022%s: lsp %p spawned PID %d\u005cn\u0022, __func__, lsp,\n+\t\t\t lsp-\u003echild_pid);\n+\n+\t\tlws_sul_schedule(context, i-\u003etsi, \u0026lsp-\u003esul, lws_spawn_timeout,\n+\t\t\t\t i-\u003etimeout_us ? i-\u003etimeout_us :\n+\t\t\t\t\t\t 300 * LWS_US_PER_SEC);\n+\n \t\tif (i-\u003eowner)\n \t\t\tlws_dll2_add_head(\u0026lsp-\u003edll, i-\u003eowner);\n \n@@ -444,7 +445,7 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)\n \t\tlwsl_notice(\u0022%s: Failed to cd to %s\u005cn\u0022, __func__, wd);\n \n \tfor (m \u003d 0; m \u003c 3; m++) {\n-\t\tif (dup2(lsp-\u003epipe_fds[m][!(m \u003d\u003d 0)], m) \u003c 0) {\n+\t\tif (dup2(lsp-\u003epipe_fds[m][m !\u003d 0], m) \u003c 0) {\n \t\t\tlwsl_err(\u0022%s: stdin dup2 failed\u005cn\u0022, __func__);\n \t\t\tgoto bail3;\n \t\t}\n@@ -457,8 +458,7 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)\n \t\t * identity during this pre-exec() time\n \t\t */\n #if !defined(LWS_HAVE_VFORK) || !defined(LWS_HAVE_EXECVPE)\n-\t\tclose(lsp-\u003epipe_fds[m][!(m \u003d\u003d 0)]);\n-\t\tclose(lsp-\u003epipe_fds[m][!!(m \u003d\u003d 0)]);\n+\t\tclose(lsp-\u003epipe_fds[m][m !\u003d 0]);\n #endif\n \t}\n \n","s":{"c":1752654267,"u": 1959}} ],"g": 3686,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}