From 08cdc2020145eb7dde2205c99b8de06cd46ae970 Mon Sep 17 00:00:00 2001 From: Nick Logan Date: Wed, 21 Feb 2018 20:00:49 -0500 Subject: [PATCH 1/2] Bump libuv version 1.19.2 Resolves #757 --- 3rdparty/libuv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/libuv b/3rdparty/libuv index b0f9fb2a07..c5afc37e2a 160000 --- a/3rdparty/libuv +++ b/3rdparty/libuv @@ -1 +1 @@ -Subproject commit b0f9fb2a07a5e638b1580fe9a42a356c3ab35f37 +Subproject commit c5afc37e2a8a70d8ab0da8dac10b77ba78c0488c From 9936bccab5bf0dd655331323409dbd69ab0ab522 Mon Sep 17 00:00:00 2001 From: Nick Logan Date: Wed, 21 Feb 2018 20:44:41 -0500 Subject: [PATCH 2/2] Add getppid op Allows a child process to get the parent process id, and thus guess if it has become orphaned. See: #748 --- lib/MAST/Ops.nqp | 269 ++++++++++++++++++++++---------------------- src/core/interp.c | 4 + src/core/oplabels.h | 2 +- src/core/oplist | 1 + src/core/ops.c | 15 ++- src/core/ops.h | 139 +++++++++++------------ src/io/procops.c | 5 + src/io/procops.h | 1 + 8 files changed, 233 insertions(+), 203 deletions(-) diff --git a/lib/MAST/Ops.nqp b/lib/MAST/Ops.nqp index 31c7eda64c..c395266faa 100644 --- a/lib/MAST/Ops.nqp +++ b/lib/MAST/Ops.nqp @@ -796,74 +796,75 @@ BEGIN { 1986, 1990, 1995, - 1998, - 2001, - 2004, - 2007, - 2010, - 2014, - 2016, - 2018, - 2020, - 2022, - 2024, - 2026, - 2028, - 2030, - 2032, - 2034, - 2037, - 2040, - 2043, - 2046, + 1996, + 1999, + 2002, + 2005, + 2008, + 2011, + 2015, + 2017, + 2019, + 2021, + 2023, + 2025, + 2027, + 2029, + 2031, + 2033, + 2035, + 2038, + 2041, + 2044, 2047, - 2049, - 2053, - 2056, - 2059, - 2062, - 2065, - 2068, - 2071, - 2074, - 2077, - 2080, - 2083, - 2086, - 2089, - 2092, - 2095, - 2098, - 2101, - 2105, - 2109, - 2112, - 2115, - 2118, - 2121, - 2124, - 2127, - 2130, - 2133, - 2136, - 2139, - 2142, - 2146, - 2150, + 2048, + 2050, + 2054, + 2057, + 2060, + 2063, + 2066, + 2069, + 2072, + 2075, + 2078, + 2081, + 2084, + 2087, + 2090, + 2093, + 2096, + 2099, + 2102, + 2106, + 2110, + 2113, + 2116, + 2119, + 2122, + 2125, + 2128, + 2131, + 2134, + 2137, + 2140, + 2143, + 2147, 2151, - 2153, - 2155, - 2157, - 2161, - 2163, - 2165, - 2165, - 2165, + 2152, + 2154, + 2156, + 2158, + 2162, + 2164, + 2166, + 2166, 2166, - 2167, 2167, 2168, - 2170); + 2168, + 2169, + 2171); MAST::Ops.WHO<@counts> := nqp::list_i(0, 2, 2, @@ -1656,6 +1657,7 @@ BEGIN { 5, 4, 5, + 1, 3, 3, 3, @@ -3720,6 +3722,7 @@ BEGIN { 57, 57, 33, + 34, 65, 128, 152, @@ -4691,75 +4694,76 @@ BEGIN { 'encodeconf', 789, 'decodeconf', 790, 'decoderepconf', 791, - 'sp_guard', 792, - 'sp_guardconc', 793, - 'sp_guardtype', 794, - 'sp_guardsf', 795, - 'sp_guardsfouter', 796, - 'sp_rebless', 797, - 'sp_resolvecode', 798, - 'sp_decont', 799, - 'sp_getlex_o', 800, - 'sp_getlex_ins', 801, - 'sp_getlex_no', 802, - 'sp_getarg_o', 803, - 'sp_getarg_i', 804, - 'sp_getarg_n', 805, - 'sp_getarg_s', 806, - 'sp_fastinvoke_v', 807, - 'sp_fastinvoke_i', 808, - 'sp_fastinvoke_n', 809, - 'sp_fastinvoke_s', 810, - 'sp_fastinvoke_o', 811, - 'sp_paramnamesused', 812, - 'sp_getspeshslot', 813, - 'sp_findmeth', 814, - 'sp_fastcreate', 815, - 'sp_get_o', 816, - 'sp_get_i64', 817, - 'sp_get_i32', 818, - 'sp_get_i16', 819, - 'sp_get_i8', 820, - 'sp_get_n', 821, - 'sp_get_s', 822, - 'sp_bind_o', 823, - 'sp_bind_i64', 824, - 'sp_bind_i32', 825, - 'sp_bind_i16', 826, - 'sp_bind_i8', 827, - 'sp_bind_n', 828, - 'sp_bind_s', 829, - 'sp_p6oget_o', 830, - 'sp_p6ogetvt_o', 831, - 'sp_p6ogetvc_o', 832, - 'sp_p6oget_i', 833, - 'sp_p6oget_n', 834, - 'sp_p6oget_s', 835, - 'sp_p6obind_o', 836, - 'sp_p6obind_i', 837, - 'sp_p6obind_n', 838, - 'sp_p6obind_s', 839, - 'sp_deref_get_i64', 840, - 'sp_deref_get_n', 841, - 'sp_deref_bind_i64', 842, - 'sp_deref_bind_n', 843, - 'sp_getlexvia_o', 844, - 'sp_getlexvia_ins', 845, - 'sp_jit_enter', 846, - 'sp_boolify_iter', 847, - 'sp_boolify_iter_arr', 848, - 'sp_boolify_iter_hash', 849, - 'sp_cas_o', 850, - 'sp_atomicload_o', 851, - 'sp_atomicstore_o', 852, - 'prof_enter', 853, - 'prof_enterspesh', 854, - 'prof_enterinline', 855, - 'prof_enternative', 856, - 'prof_exit', 857, - 'prof_allocated', 858, - 'ctw_check', 859, - 'coverage_log', 860); + 'getppid', 792, + 'sp_guard', 793, + 'sp_guardconc', 794, + 'sp_guardtype', 795, + 'sp_guardsf', 796, + 'sp_guardsfouter', 797, + 'sp_rebless', 798, + 'sp_resolvecode', 799, + 'sp_decont', 800, + 'sp_getlex_o', 801, + 'sp_getlex_ins', 802, + 'sp_getlex_no', 803, + 'sp_getarg_o', 804, + 'sp_getarg_i', 805, + 'sp_getarg_n', 806, + 'sp_getarg_s', 807, + 'sp_fastinvoke_v', 808, + 'sp_fastinvoke_i', 809, + 'sp_fastinvoke_n', 810, + 'sp_fastinvoke_s', 811, + 'sp_fastinvoke_o', 812, + 'sp_paramnamesused', 813, + 'sp_getspeshslot', 814, + 'sp_findmeth', 815, + 'sp_fastcreate', 816, + 'sp_get_o', 817, + 'sp_get_i64', 818, + 'sp_get_i32', 819, + 'sp_get_i16', 820, + 'sp_get_i8', 821, + 'sp_get_n', 822, + 'sp_get_s', 823, + 'sp_bind_o', 824, + 'sp_bind_i64', 825, + 'sp_bind_i32', 826, + 'sp_bind_i16', 827, + 'sp_bind_i8', 828, + 'sp_bind_n', 829, + 'sp_bind_s', 830, + 'sp_p6oget_o', 831, + 'sp_p6ogetvt_o', 832, + 'sp_p6ogetvc_o', 833, + 'sp_p6oget_i', 834, + 'sp_p6oget_n', 835, + 'sp_p6oget_s', 836, + 'sp_p6obind_o', 837, + 'sp_p6obind_i', 838, + 'sp_p6obind_n', 839, + 'sp_p6obind_s', 840, + 'sp_deref_get_i64', 841, + 'sp_deref_get_n', 842, + 'sp_deref_bind_i64', 843, + 'sp_deref_bind_n', 844, + 'sp_getlexvia_o', 845, + 'sp_getlexvia_ins', 846, + 'sp_jit_enter', 847, + 'sp_boolify_iter', 848, + 'sp_boolify_iter_arr', 849, + 'sp_boolify_iter_hash', 850, + 'sp_cas_o', 851, + 'sp_atomicload_o', 852, + 'sp_atomicstore_o', 853, + 'prof_enter', 854, + 'prof_enterspesh', 855, + 'prof_enterinline', 856, + 'prof_enternative', 857, + 'prof_exit', 858, + 'prof_allocated', 859, + 'ctw_check', 860, + 'coverage_log', 861); MAST::Ops.WHO<@names> := nqp::list_s('no_op', 'const_i8', 'const_i16', @@ -5552,6 +5556,7 @@ BEGIN { 'encodeconf', 'decodeconf', 'decoderepconf', + 'getppid', 'sp_guard', 'sp_guardconc', 'sp_guardtype', diff --git a/src/core/interp.c b/src/core/interp.c index e212e284ea..9fa2513e97 100644 --- a/src/core/interp.c +++ b/src/core/interp.c @@ -5308,6 +5308,10 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s, GET_REG(cur_op, 6).s, GET_REG(cur_op, 8).i64); cur_op += 10; goto NEXT; + OP(getppid): + GET_REG(cur_op, 0).i64 = MVM_proc_getppid(tc); + cur_op += 2; + goto NEXT; OP(sp_guard): { MVMObject *check = GET_REG(cur_op, 0).o; MVMSTable *want = (MVMSTable *)tc->cur_frame diff --git a/src/core/oplabels.h b/src/core/oplabels.h index 0e714dd2b5..574c510408 100644 --- a/src/core/oplabels.h +++ b/src/core/oplabels.h @@ -793,6 +793,7 @@ static const void * const LABELS[] = { &&OP_encodeconf, &&OP_decodeconf, &&OP_decoderepconf, + &&OP_getppid, &&OP_sp_guard, &&OP_sp_guardconc, &&OP_sp_guardtype, @@ -1024,7 +1025,6 @@ static const void * const LABELS[] = { NULL, NULL, NULL, - NULL, &&OP_CALL_EXTOP, &&OP_CALL_EXTOP, &&OP_CALL_EXTOP, diff --git a/src/core/oplist b/src/core/oplist index 82ec6c2b9b..53bcee5fed 100644 --- a/src/core/oplist +++ b/src/core/oplist @@ -845,6 +845,7 @@ encoderepconf w(obj) r(str) r(str) r(str) r(obj) r(int64) encodeconf w(obj) r(str) r(str) r(obj) r(int64) decodeconf w(str) r(obj) r(str) r(int64) decoderepconf w(str) r(obj) r(str) r(str) r(int64) +getppid w(int64) # Spesh ops. Naming convention: start with sp_. Must all be marked .s, which # is how the validator knows to exclude them. diff --git a/src/core/ops.c b/src/core/ops.c index 4606ee1f2b..fa57864a55 100644 --- a/src/core/ops.c +++ b/src/core/ops.c @@ -10288,6 +10288,19 @@ static const MVMOpInfo MVM_op_infos[] = { 0, { MVM_operand_write_reg | MVM_operand_str, MVM_operand_read_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_str, MVM_operand_read_reg | MVM_operand_str, MVM_operand_read_reg | MVM_operand_int64 } }, + { + MVM_OP_getppid, + "getppid", + " ", + 1, + 0, + 0, + 0, + 0, + 0, + 0, + { MVM_operand_write_reg | MVM_operand_int64 } + }, { MVM_OP_sp_guard, "sp_guard", @@ -11184,7 +11197,7 @@ static const MVMOpInfo MVM_op_infos[] = { }, }; -static const unsigned short MVM_op_counts = 861; +static const unsigned short MVM_op_counts = 862; MVM_PUBLIC const MVMOpInfo * MVM_op_get_op(unsigned short op) { if (op >= MVM_op_counts) diff --git a/src/core/ops.h b/src/core/ops.h index b7c0ace634..9d9fd75727 100644 --- a/src/core/ops.h +++ b/src/core/ops.h @@ -793,75 +793,76 @@ #define MVM_OP_encodeconf 789 #define MVM_OP_decodeconf 790 #define MVM_OP_decoderepconf 791 -#define MVM_OP_sp_guard 792 -#define MVM_OP_sp_guardconc 793 -#define MVM_OP_sp_guardtype 794 -#define MVM_OP_sp_guardsf 795 -#define MVM_OP_sp_guardsfouter 796 -#define MVM_OP_sp_rebless 797 -#define MVM_OP_sp_resolvecode 798 -#define MVM_OP_sp_decont 799 -#define MVM_OP_sp_getlex_o 800 -#define MVM_OP_sp_getlex_ins 801 -#define MVM_OP_sp_getlex_no 802 -#define MVM_OP_sp_getarg_o 803 -#define MVM_OP_sp_getarg_i 804 -#define MVM_OP_sp_getarg_n 805 -#define MVM_OP_sp_getarg_s 806 -#define MVM_OP_sp_fastinvoke_v 807 -#define MVM_OP_sp_fastinvoke_i 808 -#define MVM_OP_sp_fastinvoke_n 809 -#define MVM_OP_sp_fastinvoke_s 810 -#define MVM_OP_sp_fastinvoke_o 811 -#define MVM_OP_sp_paramnamesused 812 -#define MVM_OP_sp_getspeshslot 813 -#define MVM_OP_sp_findmeth 814 -#define MVM_OP_sp_fastcreate 815 -#define MVM_OP_sp_get_o 816 -#define MVM_OP_sp_get_i64 817 -#define MVM_OP_sp_get_i32 818 -#define MVM_OP_sp_get_i16 819 -#define MVM_OP_sp_get_i8 820 -#define MVM_OP_sp_get_n 821 -#define MVM_OP_sp_get_s 822 -#define MVM_OP_sp_bind_o 823 -#define MVM_OP_sp_bind_i64 824 -#define MVM_OP_sp_bind_i32 825 -#define MVM_OP_sp_bind_i16 826 -#define MVM_OP_sp_bind_i8 827 -#define MVM_OP_sp_bind_n 828 -#define MVM_OP_sp_bind_s 829 -#define MVM_OP_sp_p6oget_o 830 -#define MVM_OP_sp_p6ogetvt_o 831 -#define MVM_OP_sp_p6ogetvc_o 832 -#define MVM_OP_sp_p6oget_i 833 -#define MVM_OP_sp_p6oget_n 834 -#define MVM_OP_sp_p6oget_s 835 -#define MVM_OP_sp_p6obind_o 836 -#define MVM_OP_sp_p6obind_i 837 -#define MVM_OP_sp_p6obind_n 838 -#define MVM_OP_sp_p6obind_s 839 -#define MVM_OP_sp_deref_get_i64 840 -#define MVM_OP_sp_deref_get_n 841 -#define MVM_OP_sp_deref_bind_i64 842 -#define MVM_OP_sp_deref_bind_n 843 -#define MVM_OP_sp_getlexvia_o 844 -#define MVM_OP_sp_getlexvia_ins 845 -#define MVM_OP_sp_jit_enter 846 -#define MVM_OP_sp_boolify_iter 847 -#define MVM_OP_sp_boolify_iter_arr 848 -#define MVM_OP_sp_boolify_iter_hash 849 -#define MVM_OP_sp_cas_o 850 -#define MVM_OP_sp_atomicload_o 851 -#define MVM_OP_sp_atomicstore_o 852 -#define MVM_OP_prof_enter 853 -#define MVM_OP_prof_enterspesh 854 -#define MVM_OP_prof_enterinline 855 -#define MVM_OP_prof_enternative 856 -#define MVM_OP_prof_exit 857 -#define MVM_OP_prof_allocated 858 -#define MVM_OP_ctw_check 859 -#define MVM_OP_coverage_log 860 +#define MVM_OP_getppid 792 +#define MVM_OP_sp_guard 793 +#define MVM_OP_sp_guardconc 794 +#define MVM_OP_sp_guardtype 795 +#define MVM_OP_sp_guardsf 796 +#define MVM_OP_sp_guardsfouter 797 +#define MVM_OP_sp_rebless 798 +#define MVM_OP_sp_resolvecode 799 +#define MVM_OP_sp_decont 800 +#define MVM_OP_sp_getlex_o 801 +#define MVM_OP_sp_getlex_ins 802 +#define MVM_OP_sp_getlex_no 803 +#define MVM_OP_sp_getarg_o 804 +#define MVM_OP_sp_getarg_i 805 +#define MVM_OP_sp_getarg_n 806 +#define MVM_OP_sp_getarg_s 807 +#define MVM_OP_sp_fastinvoke_v 808 +#define MVM_OP_sp_fastinvoke_i 809 +#define MVM_OP_sp_fastinvoke_n 810 +#define MVM_OP_sp_fastinvoke_s 811 +#define MVM_OP_sp_fastinvoke_o 812 +#define MVM_OP_sp_paramnamesused 813 +#define MVM_OP_sp_getspeshslot 814 +#define MVM_OP_sp_findmeth 815 +#define MVM_OP_sp_fastcreate 816 +#define MVM_OP_sp_get_o 817 +#define MVM_OP_sp_get_i64 818 +#define MVM_OP_sp_get_i32 819 +#define MVM_OP_sp_get_i16 820 +#define MVM_OP_sp_get_i8 821 +#define MVM_OP_sp_get_n 822 +#define MVM_OP_sp_get_s 823 +#define MVM_OP_sp_bind_o 824 +#define MVM_OP_sp_bind_i64 825 +#define MVM_OP_sp_bind_i32 826 +#define MVM_OP_sp_bind_i16 827 +#define MVM_OP_sp_bind_i8 828 +#define MVM_OP_sp_bind_n 829 +#define MVM_OP_sp_bind_s 830 +#define MVM_OP_sp_p6oget_o 831 +#define MVM_OP_sp_p6ogetvt_o 832 +#define MVM_OP_sp_p6ogetvc_o 833 +#define MVM_OP_sp_p6oget_i 834 +#define MVM_OP_sp_p6oget_n 835 +#define MVM_OP_sp_p6oget_s 836 +#define MVM_OP_sp_p6obind_o 837 +#define MVM_OP_sp_p6obind_i 838 +#define MVM_OP_sp_p6obind_n 839 +#define MVM_OP_sp_p6obind_s 840 +#define MVM_OP_sp_deref_get_i64 841 +#define MVM_OP_sp_deref_get_n 842 +#define MVM_OP_sp_deref_bind_i64 843 +#define MVM_OP_sp_deref_bind_n 844 +#define MVM_OP_sp_getlexvia_o 845 +#define MVM_OP_sp_getlexvia_ins 846 +#define MVM_OP_sp_jit_enter 847 +#define MVM_OP_sp_boolify_iter 848 +#define MVM_OP_sp_boolify_iter_arr 849 +#define MVM_OP_sp_boolify_iter_hash 850 +#define MVM_OP_sp_cas_o 851 +#define MVM_OP_sp_atomicload_o 852 +#define MVM_OP_sp_atomicstore_o 853 +#define MVM_OP_prof_enter 854 +#define MVM_OP_prof_enterspesh 855 +#define MVM_OP_prof_enterinline 856 +#define MVM_OP_prof_enternative 857 +#define MVM_OP_prof_exit 858 +#define MVM_OP_prof_allocated 859 +#define MVM_OP_ctw_check 860 +#define MVM_OP_coverage_log 861 #define MVM_OP_EXT_BASE 1024 #define MVM_OP_EXT_CU_LIMIT 1024 diff --git a/src/io/procops.c b/src/io/procops.c index c182f6186d..be628e68fb 100644 --- a/src/io/procops.c +++ b/src/io/procops.c @@ -1021,6 +1021,11 @@ MVMint64 MVM_proc_getpid(MVMThreadContext *tc) { #endif } +/* Get the process ID of the parent process */ +MVMint64 MVM_proc_getppid(MVMThreadContext *tc) { + return uv_os_getppid(); +} + /* generates a random int64 */ MVMint64 MVM_proc_rand_i(MVMThreadContext *tc) { MVMuint64 result = tinymt64_generate_uint64(tc->rand_state); diff --git a/src/io/procops.h b/src/io/procops.h index d07f2e3e44..c60b045eff 100644 --- a/src/io/procops.h +++ b/src/io/procops.h @@ -17,6 +17,7 @@ MVMObject * MVM_proc_spawn_async(MVMThreadContext *tc, MVMObject *queue, MVMObje MVMString *cwd, MVMObject *env, MVMObject *callbacks); void MVM_proc_kill_async(MVMThreadContext *tc, MVMObject *handle, MVMint64 signal); MVMint64 MVM_proc_getpid(MVMThreadContext *tc); +MVMint64 MVM_proc_getppid(MVMThreadContext *tc); MVMint64 MVM_proc_rand_i(MVMThreadContext *tc); MVMnum64 MVM_proc_rand_n(MVMThreadContext *tc); MVMnum64 MVM_proc_randscale_n(MVMThreadContext *tc, MVMnum64 scale);