| author | |
| committer | |
| log | 8b269f7e18ee1e0874b7cbf7cf2853b7e34b6a36 |
| tree | 2ddc9ef9825a4a3fe8bc88a14d5edc028ae96ea5 |
| parent | cc751c01f13658280bc48905261f316b9b58b718 |
fixes start logic for checking whether IO/POLL exist12 files changed, 579 insertions(+), 656 deletions(-)
lib/std/Io/Threaded.zig+2-2| ... | ... | @@ -75,10 +75,10 @@ const Closure = struct { |
| 75 | 75 | .none, .canceling => {}, |
| 76 | 76 | else => |tid| { |
| 77 | 77 | if (std.Thread.use_pthreads) { |
| 78 | const rc = std.c.pthread_kill(tid.toThreadId(), posix.SIG.IO); | |
| 78 | const rc = std.c.pthread_kill(tid.toThreadId(), .IO); | |
| 79 | 79 | if (is_debug) assert(rc == 0); |
| 80 | 80 | } else if (native_os == .linux) { |
| 81 | _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid.toThreadId()), posix.SIG.IO); | |
| 81 | _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid.toThreadId()), .IO); | |
| 82 | 82 | } |
| 83 | 83 | }, |
| 84 | 84 | } |
lib/std/Progress.zig+3-3| ... | ... | @@ -493,7 +493,7 @@ pub fn start(options: Options) Node { |
| 493 | 493 | .mask = posix.sigemptyset(), |
| 494 | 494 | .flags = (posix.SA.SIGINFO | posix.SA.RESTART), |
| 495 | 495 | }; |
| 496 | posix.sigaction(posix.SIG.WINCH, &act, null); | |
| 496 | posix.sigaction(.WINCH, &act, null); | |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | if (switch (global_progress.terminal_mode) { |
| ... | ... | @@ -1535,10 +1535,10 @@ fn maybeUpdateSize(resize_flag: bool) void { |
| 1535 | 1535 | } |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 1538 | fn handleSigWinch(sig: posix.SIG, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 1539 | 1539 | _ = info; |
| 1540 | 1540 | _ = ctx_ptr; |
| 1541 | assert(sig == posix.SIG.WINCH); | |
| 1541 | assert(sig == .WINCH); | |
| 1542 | 1542 | global_progress.redraw_event.set(); |
| 1543 | 1543 | } |
| 1544 | 1544 |
lib/std/c.zig+353-348| ... | ... | @@ -2587,25 +2587,24 @@ pub const SHUT = switch (native_os) { |
| 2587 | 2587 | |
| 2588 | 2588 | /// Signal types |
| 2589 | 2589 | pub const SIG = switch (native_os) { |
| 2590 | .linux => linux.SIG, | |
| 2591 | .emscripten => emscripten.SIG, | |
| 2592 | .windows => struct { | |
| 2590 | .linux, .emscripten => linux.SIG, | |
| 2591 | .windows => enum(u32) { | |
| 2593 | 2592 | /// interrupt |
| 2594 | pub const INT = 2; | |
| 2593 | INT = 2, | |
| 2595 | 2594 | /// illegal instruction - invalid function image |
| 2596 | pub const ILL = 4; | |
| 2595 | ILL = 4, | |
| 2597 | 2596 | /// floating point exception |
| 2598 | pub const FPE = 8; | |
| 2597 | FPE = 8, | |
| 2599 | 2598 | /// segment violation |
| 2600 | pub const SEGV = 11; | |
| 2599 | SEGV = 11, | |
| 2601 | 2600 | /// Software termination signal from kill |
| 2602 | pub const TERM = 15; | |
| 2601 | TERM = 15, | |
| 2603 | 2602 | /// Ctrl-Break sequence |
| 2604 | pub const BREAK = 21; | |
| 2603 | BREAK = 21, | |
| 2605 | 2604 | /// abnormal termination triggered by abort call |
| 2606 | pub const ABRT = 22; | |
| 2605 | ABRT = 22, | |
| 2607 | 2606 | /// SIGABRT compatible with other platforms, same as SIGABRT |
| 2608 | pub const ABRT_COMPAT = 6; | |
| 2607 | ABRT_COMPAT = 6, | |
| 2609 | 2608 | |
| 2610 | 2609 | // Signal action codes |
| 2611 | 2610 | /// default signal action |
| ... | ... | @@ -2621,7 +2620,7 @@ pub const SIG = switch (native_os) { |
| 2621 | 2620 | /// Signal error value (returned by signal call on error) |
| 2622 | 2621 | pub const ERR = -1; |
| 2623 | 2622 | }, |
| 2624 | .macos, .ios, .tvos, .watchos, .visionos => struct { | |
| 2623 | .macos, .ios, .tvos, .watchos, .visionos => enum(u32) { | |
| 2625 | 2624 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2626 | 2625 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2627 | 2626 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| ... | ... | @@ -2633,113 +2632,74 @@ pub const SIG = switch (native_os) { |
| 2633 | 2632 | pub const UNBLOCK = 2; |
| 2634 | 2633 | /// set specified signal set |
| 2635 | 2634 | pub const SETMASK = 3; |
| 2635 | ||
| 2636 | pub const IOT: SIG = .ABRT; | |
| 2637 | pub const POLL: SIG = .EMT; | |
| 2638 | ||
| 2636 | 2639 | /// hangup |
| 2637 | pub const HUP = 1; | |
| 2640 | HUP = 1, | |
| 2638 | 2641 | /// interrupt |
| 2639 | pub const INT = 2; | |
| 2642 | INT = 2, | |
| 2640 | 2643 | /// quit |
| 2641 | pub const QUIT = 3; | |
| 2644 | QUIT = 3, | |
| 2642 | 2645 | /// illegal instruction (not reset when caught) |
| 2643 | pub const ILL = 4; | |
| 2646 | ILL = 4, | |
| 2644 | 2647 | /// trace trap (not reset when caught) |
| 2645 | pub const TRAP = 5; | |
| 2648 | TRAP = 5, | |
| 2646 | 2649 | /// abort() |
| 2647 | pub const ABRT = 6; | |
| 2648 | /// pollable event ([XSR] generated, not supported) | |
| 2649 | pub const POLL = 7; | |
| 2650 | /// compatibility | |
| 2651 | pub const IOT = ABRT; | |
| 2650 | ABRT = 6, | |
| 2652 | 2651 | /// EMT instruction |
| 2653 | pub const EMT = 7; | |
| 2652 | EMT = 7, | |
| 2654 | 2653 | /// floating point exception |
| 2655 | pub const FPE = 8; | |
| 2654 | FPE = 8, | |
| 2656 | 2655 | /// kill (cannot be caught or ignored) |
| 2657 | pub const KILL = 9; | |
| 2656 | KILL = 9, | |
| 2658 | 2657 | /// bus error |
| 2659 | pub const BUS = 10; | |
| 2658 | BUS = 10, | |
| 2660 | 2659 | /// segmentation violation |
| 2661 | pub const SEGV = 11; | |
| 2660 | SEGV = 11, | |
| 2662 | 2661 | /// bad argument to system call |
| 2663 | pub const SYS = 12; | |
| 2662 | SYS = 12, | |
| 2664 | 2663 | /// write on a pipe with no one to read it |
| 2665 | pub const PIPE = 13; | |
| 2664 | PIPE = 13, | |
| 2666 | 2665 | /// alarm clock |
| 2667 | pub const ALRM = 14; | |
| 2666 | ALRM = 14, | |
| 2668 | 2667 | /// software termination signal from kill |
| 2669 | pub const TERM = 15; | |
| 2668 | TERM = 15, | |
| 2670 | 2669 | /// urgent condition on IO channel |
| 2671 | pub const URG = 16; | |
| 2670 | URG = 16, | |
| 2672 | 2671 | /// sendable stop signal not from tty |
| 2673 | pub const STOP = 17; | |
| 2672 | STOP = 17, | |
| 2674 | 2673 | /// stop signal from tty |
| 2675 | pub const TSTP = 18; | |
| 2674 | TSTP = 18, | |
| 2676 | 2675 | /// continue a stopped process |
| 2677 | pub const CONT = 19; | |
| 2676 | CONT = 19, | |
| 2678 | 2677 | /// to parent on child stop or exit |
| 2679 | pub const CHLD = 20; | |
| 2678 | CHLD = 20, | |
| 2680 | 2679 | /// to readers pgrp upon background tty read |
| 2681 | pub const TTIN = 21; | |
| 2680 | TTIN = 21, | |
| 2682 | 2681 | /// like TTIN for output if (tp->t_local&LTOSTOP) |
| 2683 | pub const TTOU = 22; | |
| 2682 | TTOU = 22, | |
| 2684 | 2683 | /// input/output possible signal |
| 2685 | pub const IO = 23; | |
| 2684 | IO = 23, | |
| 2686 | 2685 | /// exceeded CPU time limit |
| 2687 | pub const XCPU = 24; | |
| 2686 | XCPU = 24, | |
| 2688 | 2687 | /// exceeded file size limit |
| 2689 | pub const XFSZ = 25; | |
| 2688 | XFSZ = 25, | |
| 2690 | 2689 | /// virtual time alarm |
| 2691 | pub const VTALRM = 26; | |
| 2690 | VTALRM = 26, | |
| 2692 | 2691 | /// profiling time alarm |
| 2693 | pub const PROF = 27; | |
| 2692 | PROF = 27, | |
| 2694 | 2693 | /// window size changes |
| 2695 | pub const WINCH = 28; | |
| 2694 | WINCH = 28, | |
| 2696 | 2695 | /// information request |
| 2697 | pub const INFO = 29; | |
| 2696 | INFO = 29, | |
| 2698 | 2697 | /// user defined signal 1 |
| 2699 | pub const USR1 = 30; | |
| 2698 | USR1 = 30, | |
| 2700 | 2699 | /// user defined signal 2 |
| 2701 | pub const USR2 = 31; | |
| 2700 | USR2 = 31, | |
| 2702 | 2701 | }, |
| 2703 | .freebsd => struct { | |
| 2704 | pub const HUP = 1; | |
| 2705 | pub const INT = 2; | |
| 2706 | pub const QUIT = 3; | |
| 2707 | pub const ILL = 4; | |
| 2708 | pub const TRAP = 5; | |
| 2709 | pub const ABRT = 6; | |
| 2710 | pub const IOT = ABRT; | |
| 2711 | pub const EMT = 7; | |
| 2712 | pub const FPE = 8; | |
| 2713 | pub const KILL = 9; | |
| 2714 | pub const BUS = 10; | |
| 2715 | pub const SEGV = 11; | |
| 2716 | pub const SYS = 12; | |
| 2717 | pub const PIPE = 13; | |
| 2718 | pub const ALRM = 14; | |
| 2719 | pub const TERM = 15; | |
| 2720 | pub const URG = 16; | |
| 2721 | pub const STOP = 17; | |
| 2722 | pub const TSTP = 18; | |
| 2723 | pub const CONT = 19; | |
| 2724 | pub const CHLD = 20; | |
| 2725 | pub const TTIN = 21; | |
| 2726 | pub const TTOU = 22; | |
| 2727 | pub const IO = 23; | |
| 2728 | pub const XCPU = 24; | |
| 2729 | pub const XFSZ = 25; | |
| 2730 | pub const VTALRM = 26; | |
| 2731 | pub const PROF = 27; | |
| 2732 | pub const WINCH = 28; | |
| 2733 | pub const INFO = 29; | |
| 2734 | pub const USR1 = 30; | |
| 2735 | pub const USR2 = 31; | |
| 2736 | pub const THR = 32; | |
| 2737 | pub const LWP = THR; | |
| 2738 | pub const LIBRT = 33; | |
| 2739 | ||
| 2740 | pub const RTMIN = 65; | |
| 2741 | pub const RTMAX = 126; | |
| 2742 | ||
| 2702 | .freebsd => enum(u32) { | |
| 2743 | 2703 | pub const BLOCK = 1; |
| 2744 | 2704 | pub const UNBLOCK = 2; |
| 2745 | 2705 | pub const SETMASK = 3; |
| ... | ... | @@ -2763,8 +2723,48 @@ pub const SIG = switch (native_os) { |
| 2763 | 2723 | pub inline fn VALID(sig: usize) usize { |
| 2764 | 2724 | return sig <= MAXSIG and sig > 0; |
| 2765 | 2725 | } |
| 2726 | ||
| 2727 | pub const IOT: SIG = .ABRT; | |
| 2728 | pub const LWP: SIG = .THR; | |
| 2729 | ||
| 2730 | pub const RTMIN = 65; | |
| 2731 | pub const RTMAX = 126; | |
| 2732 | ||
| 2733 | HUP = 1, | |
| 2734 | INT = 2, | |
| 2735 | QUIT = 3, | |
| 2736 | ILL = 4, | |
| 2737 | TRAP = 5, | |
| 2738 | ABRT = 6, | |
| 2739 | EMT = 7, | |
| 2740 | FPE = 8, | |
| 2741 | KILL = 9, | |
| 2742 | BUS = 10, | |
| 2743 | SEGV = 11, | |
| 2744 | SYS = 12, | |
| 2745 | PIPE = 13, | |
| 2746 | ALRM = 14, | |
| 2747 | TERM = 15, | |
| 2748 | URG = 16, | |
| 2749 | STOP = 17, | |
| 2750 | TSTP = 18, | |
| 2751 | CONT = 19, | |
| 2752 | CHLD = 20, | |
| 2753 | TTIN = 21, | |
| 2754 | TTOU = 22, | |
| 2755 | IO = 23, | |
| 2756 | XCPU = 24, | |
| 2757 | XFSZ = 25, | |
| 2758 | VTALRM = 26, | |
| 2759 | PROF = 27, | |
| 2760 | WINCH = 28, | |
| 2761 | INFO = 29, | |
| 2762 | USR1 = 30, | |
| 2763 | USR2 = 31, | |
| 2764 | THR = 32, | |
| 2765 | LIBRT = 33, | |
| 2766 | 2766 | }, |
| 2767 | .illumos => struct { | |
| 2767 | .illumos => enum(u32) { | |
| 2768 | 2768 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2769 | 2769 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2770 | 2770 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| ... | ... | @@ -2773,54 +2773,9 @@ pub const SIG = switch (native_os) { |
| 2773 | 2773 | pub const WORDS = 4; |
| 2774 | 2774 | pub const MAXSIG = 75; |
| 2775 | 2775 | |
| 2776 | pub const SIG_BLOCK = 1; | |
| 2777 | pub const SIG_UNBLOCK = 2; | |
| 2778 | pub const SIG_SETMASK = 3; | |
| 2779 | ||
| 2780 | pub const HUP = 1; | |
| 2781 | pub const INT = 2; | |
| 2782 | pub const QUIT = 3; | |
| 2783 | pub const ILL = 4; | |
| 2784 | pub const TRAP = 5; | |
| 2785 | pub const IOT = 6; | |
| 2786 | pub const ABRT = 6; | |
| 2787 | pub const EMT = 7; | |
| 2788 | pub const FPE = 8; | |
| 2789 | pub const KILL = 9; | |
| 2790 | pub const BUS = 10; | |
| 2791 | pub const SEGV = 11; | |
| 2792 | pub const SYS = 12; | |
| 2793 | pub const PIPE = 13; | |
| 2794 | pub const ALRM = 14; | |
| 2795 | pub const TERM = 15; | |
| 2796 | pub const USR1 = 16; | |
| 2797 | pub const USR2 = 17; | |
| 2798 | pub const CLD = 18; | |
| 2799 | pub const CHLD = 18; | |
| 2800 | pub const PWR = 19; | |
| 2801 | pub const WINCH = 20; | |
| 2802 | pub const URG = 21; | |
| 2803 | pub const POLL = 22; | |
| 2804 | pub const IO = .POLL; | |
| 2805 | pub const STOP = 23; | |
| 2806 | pub const TSTP = 24; | |
| 2807 | pub const CONT = 25; | |
| 2808 | pub const TTIN = 26; | |
| 2809 | pub const TTOU = 27; | |
| 2810 | pub const VTALRM = 28; | |
| 2811 | pub const PROF = 29; | |
| 2812 | pub const XCPU = 30; | |
| 2813 | pub const XFSZ = 31; | |
| 2814 | pub const WAITING = 32; | |
| 2815 | pub const LWP = 33; | |
| 2816 | pub const FREEZE = 34; | |
| 2817 | pub const THAW = 35; | |
| 2818 | pub const CANCEL = 36; | |
| 2819 | pub const LOST = 37; | |
| 2820 | pub const XRES = 38; | |
| 2821 | pub const JVM1 = 39; | |
| 2822 | pub const JVM2 = 40; | |
| 2823 | pub const INFO = 41; | |
| 2776 | pub const BLOCK = 1; | |
| 2777 | pub const UNBLOCK = 2; | |
| 2778 | pub const SETMASK = 3; | |
| 2824 | 2779 | |
| 2825 | 2780 | pub const RTMIN = 42; |
| 2826 | 2781 | pub const RTMAX = 74; |
| ... | ... | @@ -2837,8 +2792,54 @@ pub const SIG = switch (native_os) { |
| 2837 | 2792 | pub inline fn VALID(sig: usize) usize { |
| 2838 | 2793 | return sig <= MAXSIG and sig > 0; |
| 2839 | 2794 | } |
| 2795 | ||
| 2796 | pub const POLL: SIG = .IO; | |
| 2797 | ||
| 2798 | HUP = 1, | |
| 2799 | INT = 2, | |
| 2800 | QUIT = 3, | |
| 2801 | ILL = 4, | |
| 2802 | TRAP = 5, | |
| 2803 | IOT = 6, | |
| 2804 | ABRT = 6, | |
| 2805 | EMT = 7, | |
| 2806 | FPE = 8, | |
| 2807 | KILL = 9, | |
| 2808 | BUS = 10, | |
| 2809 | SEGV = 11, | |
| 2810 | SYS = 12, | |
| 2811 | PIPE = 13, | |
| 2812 | ALRM = 14, | |
| 2813 | TERM = 15, | |
| 2814 | USR1 = 16, | |
| 2815 | USR2 = 17, | |
| 2816 | CLD = 18, | |
| 2817 | CHLD = 18, | |
| 2818 | PWR = 19, | |
| 2819 | WINCH = 20, | |
| 2820 | URG = 21, | |
| 2821 | IO = 22, | |
| 2822 | STOP = 23, | |
| 2823 | TSTP = 24, | |
| 2824 | CONT = 25, | |
| 2825 | TTIN = 26, | |
| 2826 | TTOU = 27, | |
| 2827 | VTALRM = 28, | |
| 2828 | PROF = 29, | |
| 2829 | XCPU = 30, | |
| 2830 | XFSZ = 31, | |
| 2831 | WAITING = 32, | |
| 2832 | LWP = 33, | |
| 2833 | FREEZE = 34, | |
| 2834 | THAW = 35, | |
| 2835 | CANCEL = 36, | |
| 2836 | LOST = 37, | |
| 2837 | XRES = 38, | |
| 2838 | JVM1 = 39, | |
| 2839 | JVM2 = 40, | |
| 2840 | INFO = 41, | |
| 2840 | 2841 | }, |
| 2841 | .netbsd => struct { | |
| 2842 | .netbsd => enum(u32) { | |
| 2842 | 2843 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2843 | 2844 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2844 | 2845 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| ... | ... | @@ -2850,40 +2851,6 @@ pub const SIG = switch (native_os) { |
| 2850 | 2851 | pub const UNBLOCK = 2; |
| 2851 | 2852 | pub const SETMASK = 3; |
| 2852 | 2853 | |
| 2853 | pub const HUP = 1; | |
| 2854 | pub const INT = 2; | |
| 2855 | pub const QUIT = 3; | |
| 2856 | pub const ILL = 4; | |
| 2857 | pub const TRAP = 5; | |
| 2858 | pub const ABRT = 6; | |
| 2859 | pub const IOT = ABRT; | |
| 2860 | pub const EMT = 7; | |
| 2861 | pub const FPE = 8; | |
| 2862 | pub const KILL = 9; | |
| 2863 | pub const BUS = 10; | |
| 2864 | pub const SEGV = 11; | |
| 2865 | pub const SYS = 12; | |
| 2866 | pub const PIPE = 13; | |
| 2867 | pub const ALRM = 14; | |
| 2868 | pub const TERM = 15; | |
| 2869 | pub const URG = 16; | |
| 2870 | pub const STOP = 17; | |
| 2871 | pub const TSTP = 18; | |
| 2872 | pub const CONT = 19; | |
| 2873 | pub const CHLD = 20; | |
| 2874 | pub const TTIN = 21; | |
| 2875 | pub const TTOU = 22; | |
| 2876 | pub const IO = 23; | |
| 2877 | pub const XCPU = 24; | |
| 2878 | pub const XFSZ = 25; | |
| 2879 | pub const VTALRM = 26; | |
| 2880 | pub const PROF = 27; | |
| 2881 | pub const WINCH = 28; | |
| 2882 | pub const INFO = 29; | |
| 2883 | pub const USR1 = 30; | |
| 2884 | pub const USR2 = 31; | |
| 2885 | pub const PWR = 32; | |
| 2886 | ||
| 2887 | 2854 | pub const RTMIN = 33; |
| 2888 | 2855 | pub const RTMAX = 63; |
| 2889 | 2856 | |
| ... | ... | @@ -2899,8 +2866,43 @@ pub const SIG = switch (native_os) { |
| 2899 | 2866 | pub inline fn VALID(sig: usize) usize { |
| 2900 | 2867 | return sig <= MAXSIG and sig > 0; |
| 2901 | 2868 | } |
| 2869 | ||
| 2870 | pub const IOT: SIG = .ABRT; | |
| 2871 | ||
| 2872 | HUP = 1, | |
| 2873 | INT = 2, | |
| 2874 | QUIT = 3, | |
| 2875 | ILL = 4, | |
| 2876 | TRAP = 5, | |
| 2877 | ABRT = 6, | |
| 2878 | EMT = 7, | |
| 2879 | FPE = 8, | |
| 2880 | KILL = 9, | |
| 2881 | BUS = 10, | |
| 2882 | SEGV = 11, | |
| 2883 | SYS = 12, | |
| 2884 | PIPE = 13, | |
| 2885 | ALRM = 14, | |
| 2886 | TERM = 15, | |
| 2887 | URG = 16, | |
| 2888 | STOP = 17, | |
| 2889 | TSTP = 18, | |
| 2890 | CONT = 19, | |
| 2891 | CHLD = 20, | |
| 2892 | TTIN = 21, | |
| 2893 | TTOU = 22, | |
| 2894 | IO = 23, | |
| 2895 | XCPU = 24, | |
| 2896 | XFSZ = 25, | |
| 2897 | VTALRM = 26, | |
| 2898 | PROF = 27, | |
| 2899 | WINCH = 28, | |
| 2900 | INFO = 29, | |
| 2901 | USR1 = 30, | |
| 2902 | USR2 = 31, | |
| 2903 | PWR = 32, | |
| 2902 | 2904 | }, |
| 2903 | .dragonfly => struct { | |
| 2905 | .dragonfly => enum(u32) { | |
| 2904 | 2906 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2905 | 2907 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2906 | 2908 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| ... | ... | @@ -2909,137 +2911,140 @@ pub const SIG = switch (native_os) { |
| 2909 | 2911 | pub const UNBLOCK = 2; |
| 2910 | 2912 | pub const SETMASK = 3; |
| 2911 | 2913 | |
| 2912 | pub const IOT = ABRT; | |
| 2913 | pub const HUP = 1; | |
| 2914 | pub const INT = 2; | |
| 2915 | pub const QUIT = 3; | |
| 2916 | pub const ILL = 4; | |
| 2917 | pub const TRAP = 5; | |
| 2918 | pub const ABRT = 6; | |
| 2919 | pub const EMT = 7; | |
| 2920 | pub const FPE = 8; | |
| 2921 | pub const KILL = 9; | |
| 2922 | pub const BUS = 10; | |
| 2923 | pub const SEGV = 11; | |
| 2924 | pub const SYS = 12; | |
| 2925 | pub const PIPE = 13; | |
| 2926 | pub const ALRM = 14; | |
| 2927 | pub const TERM = 15; | |
| 2928 | pub const URG = 16; | |
| 2929 | pub const STOP = 17; | |
| 2930 | pub const TSTP = 18; | |
| 2931 | pub const CONT = 19; | |
| 2932 | pub const CHLD = 20; | |
| 2933 | pub const TTIN = 21; | |
| 2934 | pub const TTOU = 22; | |
| 2935 | pub const IO = 23; | |
| 2936 | pub const XCPU = 24; | |
| 2937 | pub const XFSZ = 25; | |
| 2938 | pub const VTALRM = 26; | |
| 2939 | pub const PROF = 27; | |
| 2940 | pub const WINCH = 28; | |
| 2941 | pub const INFO = 29; | |
| 2942 | pub const USR1 = 30; | |
| 2943 | pub const USR2 = 31; | |
| 2944 | pub const THR = 32; | |
| 2945 | pub const CKPT = 33; | |
| 2946 | pub const CKPTEXIT = 34; | |
| 2947 | ||
| 2948 | 2914 | pub const WORDS = 4; |
| 2949 | }, | |
| 2950 | .haiku => struct { | |
| 2915 | ||
| 2916 | pub const IOT: SIG = .ABRT; | |
| 2917 | ||
| 2918 | HUP = 1, | |
| 2919 | INT = 2, | |
| 2920 | QUIT = 3, | |
| 2921 | ILL = 4, | |
| 2922 | TRAP = 5, | |
| 2923 | ABRT = 6, | |
| 2924 | EMT = 7, | |
| 2925 | FPE = 8, | |
| 2926 | KILL = 9, | |
| 2927 | BUS = 10, | |
| 2928 | SEGV = 11, | |
| 2929 | SYS = 12, | |
| 2930 | PIPE = 13, | |
| 2931 | ALRM = 14, | |
| 2932 | TERM = 15, | |
| 2933 | URG = 16, | |
| 2934 | STOP = 17, | |
| 2935 | TSTP = 18, | |
| 2936 | CONT = 19, | |
| 2937 | CHLD = 20, | |
| 2938 | TTIN = 21, | |
| 2939 | TTOU = 22, | |
| 2940 | IO = 23, | |
| 2941 | XCPU = 24, | |
| 2942 | XFSZ = 25, | |
| 2943 | VTALRM = 26, | |
| 2944 | PROF = 27, | |
| 2945 | WINCH = 28, | |
| 2946 | INFO = 29, | |
| 2947 | USR1 = 30, | |
| 2948 | USR2 = 31, | |
| 2949 | THR = 32, | |
| 2950 | CKPT = 33, | |
| 2951 | CKPTEXIT = 34, | |
| 2952 | }, | |
| 2953 | .haiku => enum(u32) { | |
| 2951 | 2954 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2952 | 2955 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2953 | 2956 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2954 | 2957 | |
| 2955 | 2958 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); |
| 2956 | 2959 | |
| 2957 | pub const HUP = 1; | |
| 2958 | pub const INT = 2; | |
| 2959 | pub const QUIT = 3; | |
| 2960 | pub const ILL = 4; | |
| 2961 | pub const CHLD = 5; | |
| 2962 | pub const ABRT = 6; | |
| 2963 | pub const IOT = ABRT; | |
| 2964 | pub const PIPE = 7; | |
| 2965 | pub const FPE = 8; | |
| 2966 | pub const KILL = 9; | |
| 2967 | pub const STOP = 10; | |
| 2968 | pub const SEGV = 11; | |
| 2969 | pub const CONT = 12; | |
| 2970 | pub const TSTP = 13; | |
| 2971 | pub const ALRM = 14; | |
| 2972 | pub const TERM = 15; | |
| 2973 | pub const TTIN = 16; | |
| 2974 | pub const TTOU = 17; | |
| 2975 | pub const USR1 = 18; | |
| 2976 | pub const USR2 = 19; | |
| 2977 | pub const WINCH = 20; | |
| 2978 | pub const KILLTHR = 21; | |
| 2979 | pub const TRAP = 22; | |
| 2980 | pub const POLL = 23; | |
| 2981 | pub const PROF = 24; | |
| 2982 | pub const SYS = 25; | |
| 2983 | pub const URG = 26; | |
| 2984 | pub const VTALRM = 27; | |
| 2985 | pub const XCPU = 28; | |
| 2986 | pub const XFSZ = 29; | |
| 2987 | pub const BUS = 30; | |
| 2988 | pub const RESERVED1 = 31; | |
| 2989 | pub const RESERVED2 = 32; | |
| 2990 | ||
| 2991 | 2960 | pub const BLOCK = 1; |
| 2992 | 2961 | pub const UNBLOCK = 2; |
| 2993 | 2962 | pub const SETMASK = 3; |
| 2963 | ||
| 2964 | pub const IOT: SIG = .ABRT; | |
| 2965 | ||
| 2966 | HUP = 1, | |
| 2967 | INT = 2, | |
| 2968 | QUIT = 3, | |
| 2969 | ILL = 4, | |
| 2970 | CHLD = 5, | |
| 2971 | ABRT = 6, | |
| 2972 | PIPE = 7, | |
| 2973 | FPE = 8, | |
| 2974 | KILL = 9, | |
| 2975 | STOP = 10, | |
| 2976 | SEGV = 11, | |
| 2977 | CONT = 12, | |
| 2978 | TSTP = 13, | |
| 2979 | ALRM = 14, | |
| 2980 | TERM = 15, | |
| 2981 | TTIN = 16, | |
| 2982 | TTOU = 17, | |
| 2983 | USR1 = 18, | |
| 2984 | USR2 = 19, | |
| 2985 | WINCH = 20, | |
| 2986 | KILLTHR = 21, | |
| 2987 | TRAP = 22, | |
| 2988 | POLL = 23, | |
| 2989 | PROF = 24, | |
| 2990 | SYS = 25, | |
| 2991 | URG = 26, | |
| 2992 | VTALRM = 27, | |
| 2993 | XCPU = 28, | |
| 2994 | XFSZ = 29, | |
| 2995 | BUS = 30, | |
| 2996 | RESERVED1 = 31, | |
| 2997 | RESERVED2 = 32, | |
| 2994 | 2998 | }, |
| 2995 | .openbsd => struct { | |
| 2999 | .openbsd => enum(u32) { | |
| 2996 | 3000 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 2997 | 3001 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 2998 | 3002 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 2999 | 3003 | pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2); |
| 3000 | 3004 | pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3); |
| 3001 | 3005 | |
| 3002 | pub const HUP = 1; | |
| 3003 | pub const INT = 2; | |
| 3004 | pub const QUIT = 3; | |
| 3005 | pub const ILL = 4; | |
| 3006 | pub const TRAP = 5; | |
| 3007 | pub const ABRT = 6; | |
| 3008 | pub const IOT = ABRT; | |
| 3009 | pub const EMT = 7; | |
| 3010 | pub const FPE = 8; | |
| 3011 | pub const KILL = 9; | |
| 3012 | pub const BUS = 10; | |
| 3013 | pub const SEGV = 11; | |
| 3014 | pub const SYS = 12; | |
| 3015 | pub const PIPE = 13; | |
| 3016 | pub const ALRM = 14; | |
| 3017 | pub const TERM = 15; | |
| 3018 | pub const URG = 16; | |
| 3019 | pub const STOP = 17; | |
| 3020 | pub const TSTP = 18; | |
| 3021 | pub const CONT = 19; | |
| 3022 | pub const CHLD = 20; | |
| 3023 | pub const TTIN = 21; | |
| 3024 | pub const TTOU = 22; | |
| 3025 | pub const IO = 23; | |
| 3026 | pub const XCPU = 24; | |
| 3027 | pub const XFSZ = 25; | |
| 3028 | pub const VTALRM = 26; | |
| 3029 | pub const PROF = 27; | |
| 3030 | pub const WINCH = 28; | |
| 3031 | pub const INFO = 29; | |
| 3032 | pub const USR1 = 30; | |
| 3033 | pub const USR2 = 31; | |
| 3034 | pub const PWR = 32; | |
| 3035 | ||
| 3036 | 3006 | pub const BLOCK = 1; |
| 3037 | 3007 | pub const UNBLOCK = 2; |
| 3038 | 3008 | pub const SETMASK = 3; |
| 3009 | ||
| 3010 | pub const IOT: SIG = .ABRT; | |
| 3011 | ||
| 3012 | HUP = 1, | |
| 3013 | INT = 2, | |
| 3014 | QUIT = 3, | |
| 3015 | ILL = 4, | |
| 3016 | TRAP = 5, | |
| 3017 | ABRT = 6, | |
| 3018 | EMT = 7, | |
| 3019 | FPE = 8, | |
| 3020 | KILL = 9, | |
| 3021 | BUS = 10, | |
| 3022 | SEGV = 11, | |
| 3023 | SYS = 12, | |
| 3024 | PIPE = 13, | |
| 3025 | ALRM = 14, | |
| 3026 | TERM = 15, | |
| 3027 | URG = 16, | |
| 3028 | STOP = 17, | |
| 3029 | TSTP = 18, | |
| 3030 | CONT = 19, | |
| 3031 | CHLD = 20, | |
| 3032 | TTIN = 21, | |
| 3033 | TTOU = 22, | |
| 3034 | IO = 23, | |
| 3035 | XCPU = 24, | |
| 3036 | XFSZ = 25, | |
| 3037 | VTALRM = 26, | |
| 3038 | PROF = 27, | |
| 3039 | WINCH = 28, | |
| 3040 | INFO = 29, | |
| 3041 | USR1 = 30, | |
| 3042 | USR2 = 31, | |
| 3043 | PWR = 32, | |
| 3039 | 3044 | }, |
| 3040 | 3045 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal.h |
| 3041 | 3046 | // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h |
| 3042 | .serenity => struct { | |
| 3047 | .serenity => enum(u32) { | |
| 3043 | 3048 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3044 | 3049 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3045 | 3050 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| ... | ... | @@ -3048,39 +3053,39 @@ pub const SIG = switch (native_os) { |
| 3048 | 3053 | pub const UNBLOCK = 2; |
| 3049 | 3054 | pub const SETMASK = 3; |
| 3050 | 3055 | |
| 3051 | pub const INVAL = 0; | |
| 3052 | pub const HUP = 1; | |
| 3053 | pub const INT = 2; | |
| 3054 | pub const QUIT = 3; | |
| 3055 | pub const ILL = 4; | |
| 3056 | pub const TRAP = 5; | |
| 3057 | pub const ABRT = 6; | |
| 3058 | pub const BUS = 7; | |
| 3059 | pub const FPE = 8; | |
| 3060 | pub const KILL = 9; | |
| 3061 | pub const USR1 = 10; | |
| 3062 | pub const SEGV = 11; | |
| 3063 | pub const USR2 = 12; | |
| 3064 | pub const PIPE = 13; | |
| 3065 | pub const ALRM = 14; | |
| 3066 | pub const TERM = 15; | |
| 3067 | pub const STKFLT = 16; | |
| 3068 | pub const CHLD = 17; | |
| 3069 | pub const CONT = 18; | |
| 3070 | pub const STOP = 19; | |
| 3071 | pub const TSTP = 20; | |
| 3072 | pub const TTIN = 21; | |
| 3073 | pub const TTOU = 22; | |
| 3074 | pub const URG = 23; | |
| 3075 | pub const XCPU = 24; | |
| 3076 | pub const XFSZ = 25; | |
| 3077 | pub const VTALRM = 26; | |
| 3078 | pub const PROF = 27; | |
| 3079 | pub const WINCH = 28; | |
| 3080 | pub const IO = 29; | |
| 3081 | pub const INFO = 30; | |
| 3082 | pub const SYS = 31; | |
| 3083 | pub const CANCEL = 32; | |
| 3056 | INVAL = 0, | |
| 3057 | HUP = 1, | |
| 3058 | INT = 2, | |
| 3059 | QUIT = 3, | |
| 3060 | ILL = 4, | |
| 3061 | TRAP = 5, | |
| 3062 | ABRT = 6, | |
| 3063 | BUS = 7, | |
| 3064 | FPE = 8, | |
| 3065 | KILL = 9, | |
| 3066 | USR1 = 10, | |
| 3067 | SEGV = 11, | |
| 3068 | USR2 = 12, | |
| 3069 | PIPE = 13, | |
| 3070 | ALRM = 14, | |
| 3071 | TERM = 15, | |
| 3072 | STKFLT = 16, | |
| 3073 | CHLD = 17, | |
| 3074 | CONT = 18, | |
| 3075 | STOP = 19, | |
| 3076 | TSTP = 20, | |
| 3077 | TTIN = 21, | |
| 3078 | TTOU = 22, | |
| 3079 | URG = 23, | |
| 3080 | XCPU = 24, | |
| 3081 | XFSZ = 25, | |
| 3082 | VTALRM = 26, | |
| 3083 | PROF = 27, | |
| 3084 | WINCH = 28, | |
| 3085 | IO = 29, | |
| 3086 | INFO = 30, | |
| 3087 | SYS = 31, | |
| 3088 | CANCEL = 32, | |
| 3084 | 3089 | }, |
| 3085 | 3090 | else => void, |
| 3086 | 3091 | }; |
| ... | ... | @@ -3117,8 +3122,8 @@ pub const SYS = switch (native_os) { |
| 3117 | 3122 | |
| 3118 | 3123 | /// A common format for the Sigaction struct across a variety of Linux flavors. |
| 3119 | 3124 | const common_linux_Sigaction = extern struct { |
| 3120 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3121 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3125 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3126 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3122 | 3127 | |
| 3123 | 3128 | handler: extern union { |
| 3124 | 3129 | handler: ?handler_fn, |
| ... | ... | @@ -3139,8 +3144,8 @@ pub const Sigaction = switch (native_os) { |
| 3139 | 3144 | => if (builtin.target.abi.isMusl()) |
| 3140 | 3145 | common_linux_Sigaction |
| 3141 | 3146 | else if (builtin.target.ptrBitWidth() == 64) extern struct { |
| 3142 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3143 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3147 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3148 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3144 | 3149 | |
| 3145 | 3150 | flags: c_uint, |
| 3146 | 3151 | handler: extern union { |
| ... | ... | @@ -3150,8 +3155,8 @@ pub const Sigaction = switch (native_os) { |
| 3150 | 3155 | mask: sigset_t, |
| 3151 | 3156 | restorer: ?*const fn () callconv(.c) void = null, |
| 3152 | 3157 | } else extern struct { |
| 3153 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3154 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3158 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3159 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3155 | 3160 | |
| 3156 | 3161 | flags: c_uint, |
| 3157 | 3162 | handler: extern union { |
| ... | ... | @@ -3163,8 +3168,8 @@ pub const Sigaction = switch (native_os) { |
| 3163 | 3168 | __resv: [1]c_int = .{0}, |
| 3164 | 3169 | }, |
| 3165 | 3170 | .s390x => if (builtin.abi == .gnu) extern struct { |
| 3166 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3167 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3171 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3172 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3168 | 3173 | |
| 3169 | 3174 | handler: extern union { |
| 3170 | 3175 | handler: ?handler_fn, |
| ... | ... | @@ -3179,8 +3184,8 @@ pub const Sigaction = switch (native_os) { |
| 3179 | 3184 | }, |
| 3180 | 3185 | .emscripten => emscripten.Sigaction, |
| 3181 | 3186 | .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 3182 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3183 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3187 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3188 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3184 | 3189 | |
| 3185 | 3190 | handler: extern union { |
| 3186 | 3191 | handler: ?handler_fn, |
| ... | ... | @@ -3190,8 +3195,8 @@ pub const Sigaction = switch (native_os) { |
| 3190 | 3195 | flags: c_uint, |
| 3191 | 3196 | }, |
| 3192 | 3197 | .dragonfly, .freebsd => extern struct { |
| 3193 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3194 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3198 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3199 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3195 | 3200 | |
| 3196 | 3201 | /// signal handler |
| 3197 | 3202 | handler: extern union { |
| ... | ... | @@ -3204,8 +3209,8 @@ pub const Sigaction = switch (native_os) { |
| 3204 | 3209 | mask: sigset_t, |
| 3205 | 3210 | }, |
| 3206 | 3211 | .illumos => extern struct { |
| 3207 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3208 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3212 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3213 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3209 | 3214 | |
| 3210 | 3215 | /// signal options |
| 3211 | 3216 | flags: c_uint, |
| ... | ... | @@ -3218,8 +3223,8 @@ pub const Sigaction = switch (native_os) { |
| 3218 | 3223 | mask: sigset_t, |
| 3219 | 3224 | }, |
| 3220 | 3225 | .haiku => extern struct { |
| 3221 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3222 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3226 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3227 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3223 | 3228 | |
| 3224 | 3229 | /// signal handler |
| 3225 | 3230 | handler: extern union { |
| ... | ... | @@ -3237,8 +3242,8 @@ pub const Sigaction = switch (native_os) { |
| 3237 | 3242 | userdata: *allowzero anyopaque = undefined, |
| 3238 | 3243 | }, |
| 3239 | 3244 | .openbsd => extern struct { |
| 3240 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3241 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3245 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3246 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3242 | 3247 | |
| 3243 | 3248 | /// signal handler |
| 3244 | 3249 | handler: extern union { |
| ... | ... | @@ -3252,8 +3257,8 @@ pub const Sigaction = switch (native_os) { |
| 3252 | 3257 | }, |
| 3253 | 3258 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L39-L46 |
| 3254 | 3259 | .serenity => extern struct { |
| 3255 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 3256 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3260 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 3261 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 3257 | 3262 | |
| 3258 | 3263 | handler: extern union { |
| 3259 | 3264 | handler: ?handler_fn, |
| ... | ... | @@ -4433,7 +4438,7 @@ pub const siginfo_t = switch (native_os) { |
| 4433 | 4438 | .linux => linux.siginfo_t, |
| 4434 | 4439 | .emscripten => emscripten.siginfo_t, |
| 4435 | 4440 | .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct { |
| 4436 | signo: c_int, | |
| 4441 | signo: SIG, | |
| 4437 | 4442 | errno: c_int, |
| 4438 | 4443 | code: c_int, |
| 4439 | 4444 | pid: pid_t, |
| ... | ... | @@ -4449,7 +4454,7 @@ pub const siginfo_t = switch (native_os) { |
| 4449 | 4454 | }, |
| 4450 | 4455 | .freebsd => extern struct { |
| 4451 | 4456 | // Signal number. |
| 4452 | signo: c_int, | |
| 4457 | signo: SIG, | |
| 4453 | 4458 | // Errno association. |
| 4454 | 4459 | errno: c_int, |
| 4455 | 4460 | /// Signal code. |
| ... | ... | @@ -4492,7 +4497,7 @@ pub const siginfo_t = switch (native_os) { |
| 4492 | 4497 | }, |
| 4493 | 4498 | }, |
| 4494 | 4499 | .illumos => extern struct { |
| 4495 | signo: c_int, | |
| 4500 | signo: SIG, | |
| 4496 | 4501 | code: c_int, |
| 4497 | 4502 | errno: c_int, |
| 4498 | 4503 | // 64bit architectures insert 4bytes of padding here, this is done by |
| ... | ... | @@ -4549,7 +4554,7 @@ pub const siginfo_t = switch (native_os) { |
| 4549 | 4554 | info: netbsd._ksiginfo, |
| 4550 | 4555 | }, |
| 4551 | 4556 | .dragonfly => extern struct { |
| 4552 | signo: c_int, | |
| 4557 | signo: SIG, | |
| 4553 | 4558 | errno: c_int, |
| 4554 | 4559 | code: c_int, |
| 4555 | 4560 | pid: c_int, |
| ... | ... | @@ -4561,7 +4566,7 @@ pub const siginfo_t = switch (native_os) { |
| 4561 | 4566 | __spare__: [7]c_int, |
| 4562 | 4567 | }, |
| 4563 | 4568 | .haiku => extern struct { |
| 4564 | signo: i32, | |
| 4569 | signo: SIG, | |
| 4565 | 4570 | code: i32, |
| 4566 | 4571 | errno: i32, |
| 4567 | 4572 | |
| ... | ... | @@ -4570,7 +4575,7 @@ pub const siginfo_t = switch (native_os) { |
| 4570 | 4575 | addr: *allowzero anyopaque, |
| 4571 | 4576 | }, |
| 4572 | 4577 | .openbsd => extern struct { |
| 4573 | signo: c_int, | |
| 4578 | signo: SIG, | |
| 4574 | 4579 | code: c_int, |
| 4575 | 4580 | errno: c_int, |
| 4576 | 4581 | data: extern union { |
| ... | ... | @@ -4605,7 +4610,7 @@ pub const siginfo_t = switch (native_os) { |
| 4605 | 4610 | }, |
| 4606 | 4611 | // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L27-L37 |
| 4607 | 4612 | .serenity => extern struct { |
| 4608 | signo: c_int, | |
| 4613 | signo: SIG, | |
| 4609 | 4614 | code: c_int, |
| 4610 | 4615 | errno: c_int, |
| 4611 | 4616 | pid: pid_t, |
| ... | ... | @@ -10581,7 +10586,7 @@ pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; |
| 10581 | 10586 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; |
| 10582 | 10587 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; |
| 10583 | 10588 | pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int; |
| 10584 | pub extern "c" fn raise(sig: c_int) c_int; | |
| 10589 | pub extern "c" fn raise(sig: SIG) c_int; | |
| 10585 | 10590 | pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; |
| 10586 | 10591 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; |
| 10587 | 10592 | pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize; |
| ... | ... | @@ -10699,7 +10704,7 @@ pub const recvmsg = switch (native_os) { |
| 10699 | 10704 | else => private.recvmsg, |
| 10700 | 10705 | }; |
| 10701 | 10706 | |
| 10702 | pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int; | |
| 10707 | pub extern "c" fn kill(pid: pid_t, sig: SIG) c_int; | |
| 10703 | 10708 | |
| 10704 | 10709 | pub extern "c" fn setuid(uid: uid_t) c_int; |
| 10705 | 10710 | pub extern "c" fn setgid(gid: gid_t) c_int; |
| ... | ... | @@ -10763,7 +10768,7 @@ pub const pthread_setname_np = switch (native_os) { |
| 10763 | 10768 | }; |
| 10764 | 10769 | |
| 10765 | 10770 | pub extern "c" fn pthread_getname_np(thread: pthread_t, name: [*:0]u8, len: usize) c_int; |
| 10766 | pub extern "c" fn pthread_kill(pthread_t, signal: c_int) c_int; | |
| 10771 | pub extern "c" fn pthread_kill(pthread_t, signal: SIG) c_int; | |
| 10767 | 10772 | |
| 10768 | 10773 | pub const pthread_threadid_np = switch (native_os) { |
| 10769 | 10774 | .macos, .ios, .tvos, .watchos, .visionos => private.pthread_threadid_np, |
| ... | ... | @@ -11356,12 +11361,12 @@ const private = struct { |
| 11356 | 11361 | extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize; |
| 11357 | 11362 | extern "c" fn sched_yield() c_int; |
| 11358 | 11363 | extern "c" fn sendfile(out_fd: fd_t, in_fd: fd_t, offset: ?*off_t, count: usize) isize; |
| 11359 | extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | |
| 11360 | extern "c" fn sigdelset(set: ?*sigset_t, signo: c_int) c_int; | |
| 11361 | extern "c" fn sigaddset(set: ?*sigset_t, signo: c_int) c_int; | |
| 11364 | extern "c" fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | |
| 11365 | extern "c" fn sigdelset(set: ?*sigset_t, signo: SIG) c_int; | |
| 11366 | extern "c" fn sigaddset(set: ?*sigset_t, signo: SIG) c_int; | |
| 11362 | 11367 | extern "c" fn sigfillset(set: ?*sigset_t) c_int; |
| 11363 | 11368 | extern "c" fn sigemptyset(set: ?*sigset_t) c_int; |
| 11364 | extern "c" fn sigismember(set: ?*const sigset_t, signo: c_int) c_int; | |
| 11369 | extern "c" fn sigismember(set: ?*const sigset_t, signo: SIG) c_int; | |
| 11365 | 11370 | extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 11366 | 11371 | extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 11367 | 11372 | extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int; |
| ... | ... | @@ -11413,7 +11418,7 @@ const private = struct { |
| 11413 | 11418 | extern "c" fn __libc_thr_yield() c_int; |
| 11414 | 11419 | extern "c" fn __msync13(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 11415 | 11420 | extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 11416 | extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | |
| 11421 | extern "c" fn __sigaction14(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int; | |
| 11417 | 11422 | extern "c" fn __sigemptyset14(set: ?*sigset_t) c_int; |
| 11418 | 11423 | extern "c" fn __sigfillset14(set: ?*sigset_t) c_int; |
| 11419 | 11424 | extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
lib/std/debug.zig+10-10| ... | ... | @@ -1409,10 +1409,10 @@ pub fn maybeEnableSegfaultHandler() void { |
| 1409 | 1409 | var windows_segfault_handle: ?windows.HANDLE = null; |
| 1410 | 1410 | |
| 1411 | 1411 | pub fn updateSegfaultHandler(act: ?*const posix.Sigaction) void { |
| 1412 | posix.sigaction(posix.SIG.SEGV, act, null); | |
| 1413 | posix.sigaction(posix.SIG.ILL, act, null); | |
| 1414 | posix.sigaction(posix.SIG.BUS, act, null); | |
| 1415 | posix.sigaction(posix.SIG.FPE, act, null); | |
| 1412 | posix.sigaction(.SEGV, act, null); | |
| 1413 | posix.sigaction(.ILL, act, null); | |
| 1414 | posix.sigaction(.BUS, act, null); | |
| 1415 | posix.sigaction(.FPE, act, null); | |
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | /// Attaches a global handler for several signals which, when triggered, prints output to stderr |
| ... | ... | @@ -1457,7 +1457,7 @@ fn resetSegfaultHandler() void { |
| 1457 | 1457 | updateSegfaultHandler(&act); |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn { | |
| 1460 | fn handleSegfaultPosix(sig: posix.SIG, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn { | |
| 1461 | 1461 | if (use_trap_panic) @trap(); |
| 1462 | 1462 | const addr: ?usize, const name: []const u8 = info: { |
| 1463 | 1463 | if (native_os == .linux and native_arch == .x86_64) { |
| ... | ... | @@ -1469,7 +1469,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa |
| 1469 | 1469 | // for example when reading/writing model-specific registers |
| 1470 | 1470 | // by executing `rdmsr` or `wrmsr` in user-space (unprivileged mode). |
| 1471 | 1471 | const SI_KERNEL = 0x80; |
| 1472 | if (sig == posix.SIG.SEGV and info.code == SI_KERNEL) { | |
| 1472 | if (sig == .SEGV and info.code == SI_KERNEL) { | |
| 1473 | 1473 | break :info .{ null, "General protection exception" }; |
| 1474 | 1474 | } |
| 1475 | 1475 | } |
| ... | ... | @@ -1496,10 +1496,10 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa |
| 1496 | 1496 | else => comptime unreachable, |
| 1497 | 1497 | }; |
| 1498 | 1498 | const name = switch (sig) { |
| 1499 | posix.SIG.SEGV => "Segmentation fault", | |
| 1500 | posix.SIG.ILL => "Illegal instruction", | |
| 1501 | posix.SIG.BUS => "Bus error", | |
| 1502 | posix.SIG.FPE => "Arithmetic exception", | |
| 1499 | .SEGV => "Segmentation fault", | |
| 1500 | .ILL => "Illegal instruction", | |
| 1501 | .BUS => "Bus error", | |
| 1502 | .FPE => "Arithmetic exception", | |
| 1503 | 1503 | else => unreachable, |
| 1504 | 1504 | }; |
| 1505 | 1505 | break :info .{ addr, name }; |
lib/std/os/emscripten.zig+1-44| ... | ... | @@ -479,50 +479,7 @@ pub const SHUT = struct { |
| 479 | 479 | pub const RDWR = 2; |
| 480 | 480 | }; |
| 481 | 481 | |
| 482 | pub const SIG = struct { | |
| 483 | pub const BLOCK = 0; | |
| 484 | pub const UNBLOCK = 1; | |
| 485 | pub const SETMASK = 2; | |
| 486 | ||
| 487 | pub const HUP = 1; | |
| 488 | pub const INT = 2; | |
| 489 | pub const QUIT = 3; | |
| 490 | pub const ILL = 4; | |
| 491 | pub const TRAP = 5; | |
| 492 | pub const ABRT = 6; | |
| 493 | pub const IOT = ABRT; | |
| 494 | pub const BUS = 7; | |
| 495 | pub const FPE = 8; | |
| 496 | pub const KILL = 9; | |
| 497 | pub const USR1 = 10; | |
| 498 | pub const SEGV = 11; | |
| 499 | pub const USR2 = 12; | |
| 500 | pub const PIPE = 13; | |
| 501 | pub const ALRM = 14; | |
| 502 | pub const TERM = 15; | |
| 503 | pub const STKFLT = 16; | |
| 504 | pub const CHLD = 17; | |
| 505 | pub const CONT = 18; | |
| 506 | pub const STOP = 19; | |
| 507 | pub const TSTP = 20; | |
| 508 | pub const TTIN = 21; | |
| 509 | pub const TTOU = 22; | |
| 510 | pub const URG = 23; | |
| 511 | pub const XCPU = 24; | |
| 512 | pub const XFSZ = 25; | |
| 513 | pub const VTALRM = 26; | |
| 514 | pub const PROF = 27; | |
| 515 | pub const WINCH = 28; | |
| 516 | pub const IO = 29; | |
| 517 | pub const POLL = 29; | |
| 518 | pub const PWR = 30; | |
| 519 | pub const SYS = 31; | |
| 520 | pub const UNUSED = SIG.SYS; | |
| 521 | ||
| 522 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(std.math.maxInt(usize)); | |
| 523 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); | |
| 524 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); | |
| 525 | }; | |
| 482 | pub const SIG = linux.SIG; | |
| 526 | 483 | |
| 527 | 484 | pub const Sigaction = extern struct { |
| 528 | 485 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; |
lib/std/os/linux.zig+139-137| ... | ... | @@ -622,7 +622,7 @@ pub fn fork() usize { |
| 622 | 622 | } else if (@hasField(SYS, "fork")) { |
| 623 | 623 | return syscall0(.fork); |
| 624 | 624 | } else { |
| 625 | return syscall2(.clone, SIG.CHLD, 0); | |
| 625 | return syscall2(.clone, @intFromEnum(SIG.CHLD), 0); | |
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
| ... | ... | @@ -1532,16 +1532,16 @@ pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { |
| 1532 | 1532 | return syscall3(.getrandom, @intFromPtr(buf), count, flags); |
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | pub fn kill(pid: pid_t, sig: i32) usize { | |
| 1536 | return syscall2(.kill, @as(usize, @bitCast(@as(isize, pid))), @as(usize, @bitCast(@as(isize, sig)))); | |
| 1535 | pub fn kill(pid: pid_t, sig: SIG) usize { | |
| 1536 | return syscall2(.kill, @as(usize, @bitCast(@as(isize, pid))), @intFromEnum(sig)); | |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | pub fn tkill(tid: pid_t, sig: i32) usize { | |
| 1540 | return syscall2(.tkill, @as(usize, @bitCast(@as(isize, tid))), @as(usize, @bitCast(@as(isize, sig)))); | |
| 1539 | pub fn tkill(tid: pid_t, sig: SIG) usize { | |
| 1540 | return syscall2(.tkill, @as(usize, @bitCast(@as(isize, tid))), @intFromEnum(sig)); | |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | pub fn tgkill(tgid: pid_t, tid: pid_t, sig: i32) usize { | |
| 1544 | return syscall3(.tgkill, @as(usize, @bitCast(@as(isize, tgid))), @as(usize, @bitCast(@as(isize, tid))), @as(usize, @bitCast(@as(isize, sig)))); | |
| 1543 | pub fn tgkill(tgid: pid_t, tid: pid_t, sig: SIG) usize { | |
| 1544 | return syscall3(.tgkill, @as(usize, @bitCast(@as(isize, tgid))), @as(usize, @bitCast(@as(isize, tid))), @intFromEnum(sig)); | |
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) usize { |
| ... | ... | @@ -1923,11 +1923,11 @@ pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?* |
| 1923 | 1923 | return syscall4(.rt_sigprocmask, flags, @intFromPtr(set), @intFromPtr(oldset), NSIG / 8); |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | pub fn sigaction(sig: u8, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize { | |
| 1927 | assert(sig > 0); | |
| 1928 | assert(sig < NSIG); | |
| 1929 | assert(sig != SIG.KILL); | |
| 1930 | assert(sig != SIG.STOP); | |
| 1926 | pub fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize { | |
| 1927 | assert(@intFromEnum(sig) > 0); | |
| 1928 | assert(@intFromEnum(sig) < NSIG); | |
| 1929 | assert(sig != .KILL); | |
| 1930 | assert(sig != .STOP); | |
| 1931 | 1931 | |
| 1932 | 1932 | var ksa: k_sigaction = undefined; |
| 1933 | 1933 | var oldksa: k_sigaction = undefined; |
| ... | ... | @@ -1958,8 +1958,8 @@ pub fn sigaction(sig: u8, noalias act: ?*const Sigaction, noalias oact: ?*Sigact |
| 1958 | 1958 | |
| 1959 | 1959 | const result = switch (native_arch) { |
| 1960 | 1960 | // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. |
| 1961 | .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size), | |
| 1962 | else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), | |
| 1961 | .sparc, .sparc64 => syscall5(.rt_sigaction, @intFromEnum(sig), ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size), | |
| 1962 | else => syscall4(.rt_sigaction, @intFromEnum(sig), ksa_arg, oldksa_arg, mask_size), | |
| 1963 | 1963 | }; |
| 1964 | 1964 | if (E.init(result) != .SUCCESS) return result; |
| 1965 | 1965 | |
| ... | ... | @@ -2009,27 +2009,27 @@ pub fn sigfillset() sigset_t { |
| 2009 | 2009 | return [_]SigsetElement{~@as(SigsetElement, 0)} ** sigset_len; |
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | fn sigset_bit_index(sig: usize) struct { word: usize, mask: SigsetElement } { | |
| 2013 | assert(sig > 0); | |
| 2014 | assert(sig < NSIG); | |
| 2015 | const bit = sig - 1; | |
| 2012 | fn sigset_bit_index(sig: SIG) struct { word: usize, mask: SigsetElement } { | |
| 2013 | assert(@intFromEnum(sig) > 0); | |
| 2014 | assert(@intFromEnum(sig) < NSIG); | |
| 2015 | const bit = @intFromEnum(sig) - 1; | |
| 2016 | 2016 | return .{ |
| 2017 | 2017 | .word = bit / @bitSizeOf(SigsetElement), |
| 2018 | 2018 | .mask = @as(SigsetElement, 1) << @truncate(bit % @bitSizeOf(SigsetElement)), |
| 2019 | 2019 | }; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | pub fn sigaddset(set: *sigset_t, sig: usize) void { | |
| 2022 | pub fn sigaddset(set: *sigset_t, sig: SIG) void { | |
| 2023 | 2023 | const index = sigset_bit_index(sig); |
| 2024 | 2024 | (set.*)[index.word] |= index.mask; |
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | pub fn sigdelset(set: *sigset_t, sig: usize) void { | |
| 2027 | pub fn sigdelset(set: *sigset_t, sig: SIG) void { | |
| 2028 | 2028 | const index = sigset_bit_index(sig); |
| 2029 | 2029 | (set.*)[index.word] ^= index.mask; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | pub fn sigismember(set: *const sigset_t, sig: usize) bool { | |
| 2032 | pub fn sigismember(set: *const sigset_t, sig: SIG) bool { | |
| 2033 | 2033 | const index = sigset_bit_index(sig); |
| 2034 | 2034 | return ((set.*)[index.word] & index.mask) != 0; |
| 2035 | 2035 | } |
| ... | ... | @@ -2635,11 +2635,11 @@ pub fn pidfd_getfd(pidfd: fd_t, targetfd: fd_t, flags: u32) usize { |
| 2635 | 2635 | ); |
| 2636 | 2636 | } |
| 2637 | 2637 | |
| 2638 | pub fn pidfd_send_signal(pidfd: fd_t, sig: i32, info: ?*siginfo_t, flags: u32) usize { | |
| 2638 | pub fn pidfd_send_signal(pidfd: fd_t, sig: SIG, info: ?*siginfo_t, flags: u32) usize { | |
| 2639 | 2639 | return syscall4( |
| 2640 | 2640 | .pidfd_send_signal, |
| 2641 | 2641 | @as(usize, @bitCast(@as(isize, pidfd))), |
| 2642 | @as(usize, @bitCast(@as(isize, sig))), | |
| 2642 | @intFromEnum(sig), | |
| 2643 | 2643 | @intFromPtr(info), |
| 2644 | 2644 | flags, |
| 2645 | 2645 | ); |
| ... | ... | @@ -3736,136 +3736,138 @@ pub const SA = if (is_mips) struct { |
| 3736 | 3736 | pub const RESTORER = 0x04000000; |
| 3737 | 3737 | }; |
| 3738 | 3738 | |
| 3739 | pub const SIG = if (is_mips) struct { | |
| 3739 | pub const SIG = if (is_mips) enum(u32) { | |
| 3740 | 3740 | pub const BLOCK = 1; |
| 3741 | 3741 | pub const UNBLOCK = 2; |
| 3742 | 3742 | pub const SETMASK = 3; |
| 3743 | 3743 | |
| 3744 | // https://github.com/torvalds/linux/blob/ca91b9500108d4cf083a635c2e11c884d5dd20ea/arch/mips/include/uapi/asm/signal.h#L25 | |
| 3745 | pub const HUP = 1; | |
| 3746 | pub const INT = 2; | |
| 3747 | pub const QUIT = 3; | |
| 3748 | pub const ILL = 4; | |
| 3749 | pub const TRAP = 5; | |
| 3750 | pub const ABRT = 6; | |
| 3751 | pub const IOT = ABRT; | |
| 3752 | pub const EMT = 7; | |
| 3753 | pub const FPE = 8; | |
| 3754 | pub const KILL = 9; | |
| 3755 | pub const BUS = 10; | |
| 3756 | pub const SEGV = 11; | |
| 3757 | pub const SYS = 12; | |
| 3758 | pub const PIPE = 13; | |
| 3759 | pub const ALRM = 14; | |
| 3760 | pub const TERM = 15; | |
| 3761 | pub const USR1 = 16; | |
| 3762 | pub const USR2 = 17; | |
| 3763 | pub const CHLD = 18; | |
| 3764 | pub const PWR = 19; | |
| 3765 | pub const WINCH = 20; | |
| 3766 | pub const URG = 21; | |
| 3767 | pub const IO = 22; | |
| 3768 | pub const POLL = IO; | |
| 3769 | pub const STOP = 23; | |
| 3770 | pub const TSTP = 24; | |
| 3771 | pub const CONT = 25; | |
| 3772 | pub const TTIN = 26; | |
| 3773 | pub const TTOU = 27; | |
| 3774 | pub const VTALRM = 28; | |
| 3775 | pub const PROF = 29; | |
| 3776 | pub const XCPU = 30; | |
| 3777 | pub const XFZ = 31; | |
| 3778 | ||
| 3779 | 3744 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3780 | 3745 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3781 | 3746 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3782 | } else if (is_sparc) struct { | |
| 3747 | ||
| 3748 | pub const IOT: SIG = .ABRT; | |
| 3749 | pub const POLL: SIG = .IO; | |
| 3750 | ||
| 3751 | // /arch/mips/include/uapi/asm/signal.h#L25 | |
| 3752 | HUP = 1, | |
| 3753 | INT = 2, | |
| 3754 | QUIT = 3, | |
| 3755 | ILL = 4, | |
| 3756 | TRAP = 5, | |
| 3757 | ABRT = 6, | |
| 3758 | EMT = 7, | |
| 3759 | FPE = 8, | |
| 3760 | KILL = 9, | |
| 3761 | BUS = 10, | |
| 3762 | SEGV = 11, | |
| 3763 | SYS = 12, | |
| 3764 | PIPE = 13, | |
| 3765 | ALRM = 14, | |
| 3766 | TERM = 15, | |
| 3767 | USR1 = 16, | |
| 3768 | USR2 = 17, | |
| 3769 | CHLD = 18, | |
| 3770 | PWR = 19, | |
| 3771 | WINCH = 20, | |
| 3772 | URG = 21, | |
| 3773 | IO = 22, | |
| 3774 | STOP = 23, | |
| 3775 | TSTP = 24, | |
| 3776 | CONT = 25, | |
| 3777 | TTIN = 26, | |
| 3778 | TTOU = 27, | |
| 3779 | VTALRM = 28, | |
| 3780 | PROF = 29, | |
| 3781 | XCPU = 30, | |
| 3782 | XFZ = 31, | |
| 3783 | } else if (is_sparc) enum(u32) { | |
| 3783 | 3784 | pub const BLOCK = 1; |
| 3784 | 3785 | pub const UNBLOCK = 2; |
| 3785 | 3786 | pub const SETMASK = 4; |
| 3786 | 3787 | |
| 3787 | pub const HUP = 1; | |
| 3788 | pub const INT = 2; | |
| 3789 | pub const QUIT = 3; | |
| 3790 | pub const ILL = 4; | |
| 3791 | pub const TRAP = 5; | |
| 3792 | pub const ABRT = 6; | |
| 3793 | pub const EMT = 7; | |
| 3794 | pub const FPE = 8; | |
| 3795 | pub const KILL = 9; | |
| 3796 | pub const BUS = 10; | |
| 3797 | pub const SEGV = 11; | |
| 3798 | pub const SYS = 12; | |
| 3799 | pub const PIPE = 13; | |
| 3800 | pub const ALRM = 14; | |
| 3801 | pub const TERM = 15; | |
| 3802 | pub const URG = 16; | |
| 3803 | pub const STOP = 17; | |
| 3804 | pub const TSTP = 18; | |
| 3805 | pub const CONT = 19; | |
| 3806 | pub const CHLD = 20; | |
| 3807 | pub const TTIN = 21; | |
| 3808 | pub const TTOU = 22; | |
| 3809 | pub const POLL = 23; | |
| 3810 | pub const XCPU = 24; | |
| 3811 | pub const XFSZ = 25; | |
| 3812 | pub const VTALRM = 26; | |
| 3813 | pub const PROF = 27; | |
| 3814 | pub const WINCH = 28; | |
| 3815 | pub const LOST = 29; | |
| 3816 | pub const USR1 = 30; | |
| 3817 | pub const USR2 = 31; | |
| 3818 | pub const IOT = ABRT; | |
| 3819 | pub const CLD = CHLD; | |
| 3820 | pub const PWR = LOST; | |
| 3821 | pub const IO = SIG.POLL; | |
| 3822 | ||
| 3823 | 3788 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3824 | 3789 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3825 | 3790 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3826 | } else struct { | |
| 3791 | ||
| 3792 | pub const IOT: SIG = .ABRT; | |
| 3793 | pub const CLD: SIG = .CHLD; | |
| 3794 | pub const PWR: SIG = .LOST; | |
| 3795 | pub const POLL: SIG = .IO; | |
| 3796 | ||
| 3797 | HUP = 1, | |
| 3798 | INT = 2, | |
| 3799 | QUIT = 3, | |
| 3800 | ILL = 4, | |
| 3801 | TRAP = 5, | |
| 3802 | ABRT = 6, | |
| 3803 | EMT = 7, | |
| 3804 | FPE = 8, | |
| 3805 | KILL = 9, | |
| 3806 | BUS = 10, | |
| 3807 | SEGV = 11, | |
| 3808 | SYS = 12, | |
| 3809 | PIPE = 13, | |
| 3810 | ALRM = 14, | |
| 3811 | TERM = 15, | |
| 3812 | URG = 16, | |
| 3813 | STOP = 17, | |
| 3814 | TSTP = 18, | |
| 3815 | CONT = 19, | |
| 3816 | CHLD = 20, | |
| 3817 | TTIN = 21, | |
| 3818 | TTOU = 22, | |
| 3819 | IO = 23, | |
| 3820 | XCPU = 24, | |
| 3821 | XFSZ = 25, | |
| 3822 | VTALRM = 26, | |
| 3823 | PROF = 27, | |
| 3824 | WINCH = 28, | |
| 3825 | LOST = 29, | |
| 3826 | USR1 = 30, | |
| 3827 | USR2 = 31, | |
| 3828 | } else enum(u32) { | |
| 3827 | 3829 | pub const BLOCK = 0; |
| 3828 | 3830 | pub const UNBLOCK = 1; |
| 3829 | 3831 | pub const SETMASK = 2; |
| 3830 | 3832 | |
| 3831 | pub const HUP = 1; | |
| 3832 | pub const INT = 2; | |
| 3833 | pub const QUIT = 3; | |
| 3834 | pub const ILL = 4; | |
| 3835 | pub const TRAP = 5; | |
| 3836 | pub const ABRT = 6; | |
| 3837 | pub const IOT = ABRT; | |
| 3838 | pub const BUS = 7; | |
| 3839 | pub const FPE = 8; | |
| 3840 | pub const KILL = 9; | |
| 3841 | pub const USR1 = 10; | |
| 3842 | pub const SEGV = 11; | |
| 3843 | pub const USR2 = 12; | |
| 3844 | pub const PIPE = 13; | |
| 3845 | pub const ALRM = 14; | |
| 3846 | pub const TERM = 15; | |
| 3847 | pub const STKFLT = 16; | |
| 3848 | pub const CHLD = 17; | |
| 3849 | pub const CONT = 18; | |
| 3850 | pub const STOP = 19; | |
| 3851 | pub const TSTP = 20; | |
| 3852 | pub const TTIN = 21; | |
| 3853 | pub const TTOU = 22; | |
| 3854 | pub const URG = 23; | |
| 3855 | pub const XCPU = 24; | |
| 3856 | pub const XFSZ = 25; | |
| 3857 | pub const VTALRM = 26; | |
| 3858 | pub const PROF = 27; | |
| 3859 | pub const WINCH = 28; | |
| 3860 | pub const IO = 29; | |
| 3861 | pub const POLL = 29; | |
| 3862 | pub const PWR = 30; | |
| 3863 | pub const SYS = 31; | |
| 3864 | pub const UNUSED = SIG.SYS; | |
| 3865 | ||
| 3866 | 3833 | pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
| 3867 | 3834 | pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
| 3868 | 3835 | pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); |
| 3836 | ||
| 3837 | pub const POLL: SIG = .IO; | |
| 3838 | pub const IOT: SIG = .ABRT; | |
| 3839 | ||
| 3840 | HUP = 1, | |
| 3841 | INT = 2, | |
| 3842 | QUIT = 3, | |
| 3843 | ILL = 4, | |
| 3844 | TRAP = 5, | |
| 3845 | ABRT = 6, | |
| 3846 | BUS = 7, | |
| 3847 | FPE = 8, | |
| 3848 | KILL = 9, | |
| 3849 | USR1 = 10, | |
| 3850 | SEGV = 11, | |
| 3851 | USR2 = 12, | |
| 3852 | PIPE = 13, | |
| 3853 | ALRM = 14, | |
| 3854 | TERM = 15, | |
| 3855 | STKFLT = 16, | |
| 3856 | CHLD = 17, | |
| 3857 | CONT = 18, | |
| 3858 | STOP = 19, | |
| 3859 | TSTP = 20, | |
| 3860 | TTIN = 21, | |
| 3861 | TTOU = 22, | |
| 3862 | URG = 23, | |
| 3863 | XCPU = 24, | |
| 3864 | XFSZ = 25, | |
| 3865 | VTALRM = 26, | |
| 3866 | PROF = 27, | |
| 3867 | WINCH = 28, | |
| 3868 | IO = 29, | |
| 3869 | PWR = 30, | |
| 3870 | SYS = 31, | |
| 3869 | 3871 | }; |
| 3870 | 3872 | |
| 3871 | 3873 | pub const kernel_rwf = u32; |
| ... | ... | @@ -5786,7 +5788,7 @@ pub const TFD = switch (native_arch) { |
| 5786 | 5788 | }; |
| 5787 | 5789 | |
| 5788 | 5790 | const k_sigaction_funcs = struct { |
| 5789 | const handler = ?*align(1) const fn (i32) callconv(.c) void; | |
| 5791 | const handler = ?*align(1) const fn (SIG) callconv(.c) void; | |
| 5790 | 5792 | const restorer = *const fn () callconv(.c) void; |
| 5791 | 5793 | }; |
| 5792 | 5794 | |
| ... | ... | @@ -5817,8 +5819,8 @@ pub const k_sigaction = switch (native_arch) { |
| 5817 | 5819 | /// |
| 5818 | 5820 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 5819 | 5821 | pub const Sigaction = struct { |
| 5820 | pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; | |
| 5821 | pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 5822 | pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void; | |
| 5823 | pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void; | |
| 5822 | 5824 | |
| 5823 | 5825 | handler: extern union { |
| 5824 | 5826 | handler: ?handler_fn, |
| ... | ... | @@ -6260,14 +6262,14 @@ const siginfo_fields_union = extern union { |
| 6260 | 6262 | |
| 6261 | 6263 | pub const siginfo_t = if (is_mips) |
| 6262 | 6264 | extern struct { |
| 6263 | signo: i32, | |
| 6265 | signo: SIG, | |
| 6264 | 6266 | code: i32, |
| 6265 | 6267 | errno: i32, |
| 6266 | 6268 | fields: siginfo_fields_union, |
| 6267 | 6269 | } |
| 6268 | 6270 | else |
| 6269 | 6271 | extern struct { |
| 6270 | signo: i32, | |
| 6272 | signo: SIG, | |
| 6271 | 6273 | errno: i32, |
| 6272 | 6274 | code: i32, |
| 6273 | 6275 | fields: siginfo_fields_union, |
lib/std/os/linux/test.zig+24-46| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("../../std.zig"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 2 | ||
| 3 | const std = @import("../../std.zig"); | |
| 4 | const assert = std.debug.assert; | |
| 3 | 5 | const linux = std.os.linux; |
| 4 | 6 | const mem = std.mem; |
| 5 | 7 | const elf = std.elf; |
| ... | ... | @@ -128,58 +130,32 @@ test "fadvise" { |
| 128 | 130 | } |
| 129 | 131 | |
| 130 | 132 | test "sigset_t" { |
| 131 | std.debug.assert(@sizeOf(linux.sigset_t) == (linux.NSIG / 8)); | |
| 133 | const SIG = linux.SIG; | |
| 134 | assert(@sizeOf(linux.sigset_t) == (linux.NSIG / 8)); | |
| 132 | 135 | |
| 133 | 136 | var sigset = linux.sigemptyset(); |
| 134 | 137 | |
| 135 | 138 | // See that none are set, then set each one, see that they're all set, then |
| 136 | 139 | // remove them all, and then see that none are set. |
| 137 | 140 | for (1..linux.NSIG) |i| { |
| 138 | try expectEqual(linux.sigismember(&sigset, @truncate(i)), false); | |
| 141 | const sig = std.meta.intToEnum(SIG, i) catch continue; | |
| 142 | try expectEqual(false, linux.sigismember(&sigset, sig)); | |
| 139 | 143 | } |
| 140 | 144 | for (1..linux.NSIG) |i| { |
| 141 | linux.sigaddset(&sigset, @truncate(i)); | |
| 145 | const sig = std.meta.intToEnum(SIG, i) catch continue; | |
| 146 | linux.sigaddset(&sigset, sig); | |
| 142 | 147 | } |
| 143 | 148 | for (1..linux.NSIG) |i| { |
| 144 | try expectEqual(linux.sigismember(&sigset, @truncate(i)), true); | |
| 149 | const sig = std.meta.intToEnum(SIG, i) catch continue; | |
| 150 | try expectEqual(true, linux.sigismember(&sigset, sig)); | |
| 145 | 151 | } |
| 146 | 152 | for (1..linux.NSIG) |i| { |
| 147 | linux.sigdelset(&sigset, @truncate(i)); | |
| 153 | const sig = std.meta.intToEnum(SIG, i) catch continue; | |
| 154 | linux.sigdelset(&sigset, sig); | |
| 148 | 155 | } |
| 149 | 156 | for (1..linux.NSIG) |i| { |
| 150 | try expectEqual(linux.sigismember(&sigset, @truncate(i)), false); | |
| 151 | } | |
| 152 | ||
| 153 | // Kernel sigset_t is either 2+ 32-bit values or 1+ 64-bit value(s). | |
| 154 | const sigset_len = @typeInfo(linux.sigset_t).array.len; | |
| 155 | const sigset_elemis64 = 64 == @bitSizeOf(@typeInfo(linux.sigset_t).array.child); | |
| 156 | ||
| 157 | linux.sigaddset(&sigset, 1); | |
| 158 | try expectEqual(sigset[0], 1); | |
| 159 | if (sigset_len > 1) { | |
| 160 | try expectEqual(sigset[1], 0); | |
| 161 | } | |
| 162 | ||
| 163 | linux.sigaddset(&sigset, 31); | |
| 164 | try expectEqual(sigset[0], 0x4000_0001); | |
| 165 | if (sigset_len > 1) { | |
| 166 | try expectEqual(sigset[1], 0); | |
| 167 | } | |
| 168 | ||
| 169 | linux.sigaddset(&sigset, 36); | |
| 170 | if (sigset_elemis64) { | |
| 171 | try expectEqual(sigset[0], 0x8_4000_0001); | |
| 172 | } else { | |
| 173 | try expectEqual(sigset[0], 0x4000_0001); | |
| 174 | try expectEqual(sigset[1], 0x8); | |
| 175 | } | |
| 176 | ||
| 177 | linux.sigaddset(&sigset, 64); | |
| 178 | if (sigset_elemis64) { | |
| 179 | try expectEqual(sigset[0], 0x8000_0008_4000_0001); | |
| 180 | } else { | |
| 181 | try expectEqual(sigset[0], 0x4000_0001); | |
| 182 | try expectEqual(sigset[1], 0x8000_0008); | |
| 157 | const sig = std.meta.intToEnum(SIG, i) catch continue; | |
| 158 | try expectEqual(false, linux.sigismember(&sigset, sig)); | |
| 183 | 159 | } |
| 184 | 160 | } |
| 185 | 161 | |
| ... | ... | @@ -187,14 +163,16 @@ test "sigfillset" { |
| 187 | 163 | // unlike the C library, all the signals are set in the kernel-level fillset |
| 188 | 164 | const sigset = linux.sigfillset(); |
| 189 | 165 | for (1..linux.NSIG) |i| { |
| 190 | try expectEqual(linux.sigismember(&sigset, @truncate(i)), true); | |
| 166 | const sig = std.meta.intToEnum(linux.SIG, i) catch continue; | |
| 167 | try expectEqual(true, linux.sigismember(&sigset, sig)); | |
| 191 | 168 | } |
| 192 | 169 | } |
| 193 | 170 | |
| 194 | 171 | test "sigemptyset" { |
| 195 | 172 | const sigset = linux.sigemptyset(); |
| 196 | 173 | for (1..linux.NSIG) |i| { |
| 197 | try expectEqual(linux.sigismember(&sigset, @truncate(i)), false); | |
| 174 | const sig = std.meta.intToEnum(linux.SIG, i) catch continue; | |
| 175 | try expectEqual(false, linux.sigismember(&sigset, sig)); | |
| 198 | 176 | } |
| 199 | 177 | } |
| 200 | 178 | |
| ... | ... | @@ -208,14 +186,14 @@ test "sysinfo" { |
| 208 | 186 | } |
| 209 | 187 | |
| 210 | 188 | comptime { |
| 211 | std.debug.assert(128 == @as(u32, @bitCast(linux.FUTEX_OP{ .cmd = @enumFromInt(0), .private = true, .realtime = false }))); | |
| 212 | std.debug.assert(256 == @as(u32, @bitCast(linux.FUTEX_OP{ .cmd = @enumFromInt(0), .private = false, .realtime = true }))); | |
| 189 | assert(128 == @as(u32, @bitCast(linux.FUTEX_OP{ .cmd = @enumFromInt(0), .private = true, .realtime = false }))); | |
| 190 | assert(256 == @as(u32, @bitCast(linux.FUTEX_OP{ .cmd = @enumFromInt(0), .private = false, .realtime = true }))); | |
| 213 | 191 | |
| 214 | 192 | // Check futex_param4 union is packed correctly |
| 215 | 193 | const param_union = linux.futex_param4{ |
| 216 | 194 | .val2 = 0xaabbcc, |
| 217 | 195 | }; |
| 218 | std.debug.assert(@intFromPtr(param_union.timeout) == 0xaabbcc); | |
| 196 | assert(@intFromPtr(param_union.timeout) == 0xaabbcc); | |
| 219 | 197 | } |
| 220 | 198 | |
| 221 | 199 | test "futex v1" { |
| ... | ... | @@ -298,8 +276,8 @@ test "futex v1" { |
| 298 | 276 | } |
| 299 | 277 | |
| 300 | 278 | comptime { |
| 301 | std.debug.assert(2 == @as(u32, @bitCast(linux.FUTEX2_FLAGS{ .size = .U32, .private = false }))); | |
| 302 | std.debug.assert(128 == @as(u32, @bitCast(linux.FUTEX2_FLAGS{ .size = @enumFromInt(0), .private = true }))); | |
| 279 | assert(2 == @as(u32, @bitCast(linux.FUTEX2_FLAGS{ .size = .U32, .private = false }))); | |
| 280 | assert(128 == @as(u32, @bitCast(linux.FUTEX2_FLAGS{ .size = @enumFromInt(0), .private = true }))); | |
| 303 | 281 | } |
| 304 | 282 | |
| 305 | 283 | test "futex2_waitv" { |
lib/std/posix.zig+11-11| ... | ... | @@ -708,7 +708,7 @@ pub fn abort() noreturn { |
| 708 | 708 | // for user-defined signal handlers that want to restore some state in |
| 709 | 709 | // some program sections and crash in others. |
| 710 | 710 | // So, the user-installed SIGABRT handler is run, if present. |
| 711 | raise(SIG.ABRT) catch {}; | |
| 711 | raise(.ABRT) catch {}; | |
| 712 | 712 | |
| 713 | 713 | // Disable all signal handlers. |
| 714 | 714 | const filledset = linux.sigfillset(); |
| ... | ... | @@ -728,17 +728,17 @@ pub fn abort() noreturn { |
| 728 | 728 | .mask = sigemptyset(), |
| 729 | 729 | .flags = 0, |
| 730 | 730 | }; |
| 731 | sigaction(SIG.ABRT, &sigact, null); | |
| 731 | sigaction(.ABRT, &sigact, null); | |
| 732 | 732 | |
| 733 | _ = linux.tkill(linux.gettid(), SIG.ABRT); | |
| 733 | _ = linux.tkill(linux.gettid(), .ABRT); | |
| 734 | 734 | |
| 735 | 735 | var sigabrtmask = sigemptyset(); |
| 736 | sigaddset(&sigabrtmask, SIG.ABRT); | |
| 736 | sigaddset(&sigabrtmask, .ABRT); | |
| 737 | 737 | sigprocmask(SIG.UNBLOCK, &sigabrtmask, null); |
| 738 | 738 | |
| 739 | 739 | // Beyond this point should be unreachable. |
| 740 | 740 | @as(*allowzero volatile u8, @ptrFromInt(0)).* = 0; |
| 741 | raise(SIG.KILL) catch {}; | |
| 741 | raise(.KILL) catch {}; | |
| 742 | 742 | exit(127); // Pid 1 might not be signalled in some containers. |
| 743 | 743 | } |
| 744 | 744 | switch (native_os) { |
| ... | ... | @@ -749,7 +749,7 @@ pub fn abort() noreturn { |
| 749 | 749 | |
| 750 | 750 | pub const RaiseError = UnexpectedError; |
| 751 | 751 | |
| 752 | pub fn raise(sig: u8) RaiseError!void { | |
| 752 | pub fn raise(sig: SIG) RaiseError!void { | |
| 753 | 753 | if (builtin.link_libc) { |
| 754 | 754 | switch (errno(system.raise(sig))) { |
| 755 | 755 | .SUCCESS => return, |
| ... | ... | @@ -777,7 +777,7 @@ pub fn raise(sig: u8) RaiseError!void { |
| 777 | 777 | |
| 778 | 778 | pub const KillError = error{ ProcessNotFound, PermissionDenied } || UnexpectedError; |
| 779 | 779 | |
| 780 | pub fn kill(pid: pid_t, sig: u8) KillError!void { | |
| 780 | pub fn kill(pid: pid_t, sig: SIG) KillError!void { | |
| 781 | 781 | switch (errno(system.kill(pid, sig))) { |
| 782 | 782 | .SUCCESS => return, |
| 783 | 783 | .INVAL => unreachable, // invalid signal |
| ... | ... | @@ -5235,7 +5235,7 @@ pub fn sigemptyset() sigset_t { |
| 5235 | 5235 | return system.sigemptyset(); |
| 5236 | 5236 | } |
| 5237 | 5237 | |
| 5238 | pub fn sigaddset(set: *sigset_t, sig: u8) void { | |
| 5238 | pub fn sigaddset(set: *sigset_t, sig: SIG) void { | |
| 5239 | 5239 | if (builtin.link_libc) { |
| 5240 | 5240 | switch (errno(system.sigaddset(set, sig))) { |
| 5241 | 5241 | .SUCCESS => return, |
| ... | ... | @@ -5245,7 +5245,7 @@ pub fn sigaddset(set: *sigset_t, sig: u8) void { |
| 5245 | 5245 | system.sigaddset(set, sig); |
| 5246 | 5246 | } |
| 5247 | 5247 | |
| 5248 | pub fn sigdelset(set: *sigset_t, sig: u8) void { | |
| 5248 | pub fn sigdelset(set: *sigset_t, sig: SIG) void { | |
| 5249 | 5249 | if (builtin.link_libc) { |
| 5250 | 5250 | switch (errno(system.sigdelset(set, sig))) { |
| 5251 | 5251 | .SUCCESS => return, |
| ... | ... | @@ -5255,7 +5255,7 @@ pub fn sigdelset(set: *sigset_t, sig: u8) void { |
| 5255 | 5255 | system.sigdelset(set, sig); |
| 5256 | 5256 | } |
| 5257 | 5257 | |
| 5258 | pub fn sigismember(set: *const sigset_t, sig: u8) bool { | |
| 5258 | pub fn sigismember(set: *const sigset_t, sig: SIG) bool { | |
| 5259 | 5259 | if (builtin.link_libc) { |
| 5260 | 5260 | const rc = system.sigismember(set, sig); |
| 5261 | 5261 | switch (errno(rc)) { |
| ... | ... | @@ -5267,7 +5267,7 @@ pub fn sigismember(set: *const sigset_t, sig: u8) bool { |
| 5267 | 5267 | } |
| 5268 | 5268 | |
| 5269 | 5269 | /// Examine and change a signal action. |
| 5270 | pub fn sigaction(sig: u8, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) void { | |
| 5270 | pub fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) void { | |
| 5271 | 5271 | switch (errno(system.sigaction(sig, act, oact))) { |
| 5272 | 5272 | .SUCCESS => return, |
| 5273 | 5273 | // EINVAL means the signal is either invalid or some signal that cannot have its action |
lib/std/posix/test.zig+14-8| ... | ... | @@ -536,14 +536,15 @@ test "sigset empty/full" { |
| 536 | 536 | |
| 537 | 537 | var set: posix.sigset_t = posix.sigemptyset(); |
| 538 | 538 | for (1..posix.NSIG) |i| { |
| 539 | try expectEqual(false, posix.sigismember(&set, @truncate(i))); | |
| 539 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 540 | try expectEqual(false, posix.sigismember(&set, sig)); | |
| 540 | 541 | } |
| 541 | 542 | |
| 542 | 543 | // The C library can reserve some (unnamed) signals, so can't check the full |
| 543 | 544 | // NSIG set is defined, but just test a couple: |
| 544 | 545 | set = posix.sigfillset(); |
| 545 | try expectEqual(true, posix.sigismember(&set, @truncate(posix.SIG.CHLD))); | |
| 546 | try expectEqual(true, posix.sigismember(&set, @truncate(posix.SIG.INT))); | |
| 546 | try expectEqual(true, posix.sigismember(&set, .CHLD)); | |
| 547 | try expectEqual(true, posix.sigismember(&set, .INT)); | |
| 547 | 548 | } |
| 548 | 549 | |
| 549 | 550 | // Some signals (i.e., 32 - 34 on glibc/musl) are not allowed to be added to a |
| ... | ... | @@ -564,25 +565,30 @@ test "sigset add/del" { |
| 564 | 565 | // See that none are set, then set each one, see that they're all set, then |
| 565 | 566 | // remove them all, and then see that none are set. |
| 566 | 567 | for (1..posix.NSIG) |i| { |
| 567 | try expectEqual(false, posix.sigismember(&sigset, @truncate(i))); | |
| 568 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 569 | try expectEqual(false, posix.sigismember(&sigset, sig)); | |
| 568 | 570 | } |
| 569 | 571 | for (1..posix.NSIG) |i| { |
| 570 | 572 | if (!reserved_signo(i)) { |
| 571 | posix.sigaddset(&sigset, @truncate(i)); | |
| 573 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 574 | posix.sigaddset(&sigset, sig); | |
| 572 | 575 | } |
| 573 | 576 | } |
| 574 | 577 | for (1..posix.NSIG) |i| { |
| 575 | 578 | if (!reserved_signo(i)) { |
| 576 | try expectEqual(true, posix.sigismember(&sigset, @truncate(i))); | |
| 579 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 580 | try expectEqual(true, posix.sigismember(&sigset, sig)); | |
| 577 | 581 | } |
| 578 | 582 | } |
| 579 | 583 | for (1..posix.NSIG) |i| { |
| 580 | 584 | if (!reserved_signo(i)) { |
| 581 | posix.sigdelset(&sigset, @truncate(i)); | |
| 585 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 586 | posix.sigdelset(&sigset, sig); | |
| 582 | 587 | } |
| 583 | 588 | } |
| 584 | 589 | for (1..posix.NSIG) |i| { |
| 585 | try expectEqual(false, posix.sigismember(&sigset, @truncate(i))); | |
| 590 | const sig = std.meta.intToEnum(posix.SIG, i) catch continue; | |
| 591 | try expectEqual(false, posix.sigismember(&sigset, sig)); | |
| 586 | 592 | } |
| 587 | 593 | } |
| 588 | 594 |
lib/std/start.zig+9-30| ... | ... | @@ -758,45 +758,24 @@ pub fn call_wWinMain() std.os.windows.INT { |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | fn maybeIgnoreSignals() void { |
| 761 | switch (builtin.os.tag) { | |
| 762 | .linux, | |
| 763 | .plan9, | |
| 764 | .illumos, | |
| 765 | .netbsd, | |
| 766 | .openbsd, | |
| 767 | .haiku, | |
| 768 | .macos, | |
| 769 | .ios, | |
| 770 | .watchos, | |
| 771 | .tvos, | |
| 772 | .visionos, | |
| 773 | .dragonfly, | |
| 774 | .freebsd, | |
| 775 | .serenity, | |
| 776 | => {}, | |
| 777 | else => return, | |
| 778 | } | |
| 779 | 761 | const posix = std.posix; |
| 762 | if (posix.Sigaction == void) return; | |
| 780 | 763 | const act: posix.Sigaction = .{ |
| 781 | // Set handler to a noop function instead of `SIG.IGN` to prevent | |
| 764 | // Set handler to a noop function instead of `IGN` to prevent | |
| 782 | 765 | // leaking signal disposition to a child process. |
| 783 | 766 | .handler = .{ .handler = noopSigHandler }, |
| 784 | 767 | .mask = posix.sigemptyset(), |
| 785 | 768 | .flags = 0, |
| 786 | 769 | }; |
| 787 | 770 | |
| 788 | if (@hasField(posix.SIG, "POLL") and !std.options.keep_sigpoll) | |
| 789 | posix.sigaction(posix.SIG.POLL, &act, null); | |
| 771 | if (@hasField(posix.SIG, "IO") and !std.options.keep_sig_io) | |
| 772 | posix.sigaction(.IO, &act, null); | |
| 790 | 773 | |
| 791 | if (@hasField(posix.SIG, "IO") and | |
| 792 | (!@hasField(posix.SIG, "POLL") or posix.SIG.IO != posix.SIG.POLL) and | |
| 793 | !std.options.keep_sigio) | |
| 794 | { | |
| 795 | posix.sigaction(posix.SIG.IO, &act, null); | |
| 796 | } | |
| 774 | if (@hasField(posix.SIG, "POLL") and !std.options.keep_sig_poll) | |
| 775 | posix.sigaction(.POLL, &act, null); | |
| 797 | 776 | |
| 798 | if (@hasField(posix.SIG, "PIPE") and !std.options.keep_sigpipe) | |
| 799 | posix.sigaction(posix.SIG.PIPE, &act, null); | |
| 777 | if (@hasField(posix.SIG, "PIPE") and !std.options.keep_sig_pipe) | |
| 778 | posix.sigaction(.PIPE, &act, null); | |
| 800 | 779 | } |
| 801 | 780 | |
| 802 | fn noopSigHandler(_: i32) callconv(.c) void {} | |
| 781 | fn noopSigHandler(_: std.posix.SIG) callconv(.c) void {} |
lib/std/std.zig+3-3| ... | ... | @@ -144,8 +144,8 @@ pub const Options = struct { |
| 144 | 144 | |
| 145 | 145 | crypto_fork_safety: bool = true, |
| 146 | 146 | |
| 147 | keep_sigpoll: bool = false, | |
| 148 | keep_sigio: bool = false, | |
| 147 | keep_sig_poll: bool = false, | |
| 148 | keep_sig_io: bool = false, | |
| 149 | 149 | |
| 150 | 150 | /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option |
| 151 | 151 | /// to `true` to prevent that. |
| ... | ... | @@ -158,7 +158,7 @@ pub const Options = struct { |
| 158 | 158 | /// cases it's unclear why the process was terminated. By capturing SIGPIPE instead, functions that |
| 159 | 159 | /// write to broken pipes will return the EPIPE error (error.BrokenPipe) and the program can handle |
| 160 | 160 | /// it like any other error. |
| 161 | keep_sigpipe: bool = false, | |
| 161 | keep_sig_pipe: bool = false, | |
| 162 | 162 | |
| 163 | 163 | /// By default, std.http.Client will support HTTPS connections. Set this option to `true` to |
| 164 | 164 | /// disable TLS support. |
test/standalone/posix/sigaction.zig+10-14| ... | ... | @@ -17,12 +17,12 @@ fn test_sigaction() !void { |
| 17 | 17 | return; // https://github.com/ziglang/zig/issues/15381 |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | const test_signo = std.posix.SIG.URG; // URG only because it is ignored by default in debuggers | |
| 20 | const test_signo: std.posix.SIG = .URG; // URG only because it is ignored by default in debuggers | |
| 21 | 21 | |
| 22 | 22 | const S = struct { |
| 23 | 23 | var handler_called_count: u32 = 0; |
| 24 | 24 | |
| 25 | fn handler(sig: i32, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 25 | fn handler(sig: std.posix.SIG, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 26 | 26 | _ = ctx_ptr; |
| 27 | 27 | // Check that we received the correct signal. |
| 28 | 28 | const info_sig = switch (native_os) { |
| ... | ... | @@ -80,20 +80,18 @@ fn test_sigaction() !void { |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | fn test_sigset_bits() !void { |
| 83 | const NO_SIG: i32 = 0; | |
| 84 | ||
| 85 | 83 | const S = struct { |
| 86 | var expected_sig: i32 = undefined; | |
| 87 | var seen_sig: i32 = NO_SIG; | |
| 84 | var expected_sig: std.posix.SIG = undefined; | |
| 85 | var seen_sig: ?std.posix.SIG = null; | |
| 88 | 86 | |
| 89 | fn handler(sig: i32, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 87 | fn handler(sig: std.posix.SIG, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { | |
| 90 | 88 | _ = ctx_ptr; |
| 91 | 89 | |
| 92 | 90 | const info_sig = switch (native_os) { |
| 93 | 91 | .netbsd => info.info.signo, |
| 94 | 92 | else => info.signo, |
| 95 | 93 | }; |
| 96 | if (seen_sig == NO_SIG and sig == expected_sig and sig == info_sig) { | |
| 94 | if (seen_sig == null and sig == expected_sig and sig == info_sig) { | |
| 97 | 95 | seen_sig = sig; |
| 98 | 96 | } |
| 99 | 97 | } |
| ... | ... | @@ -107,11 +105,9 @@ fn test_sigset_bits() !void { |
| 107 | 105 | // big-endian), try sending a blocked signal to make sure the mask matches the |
| 108 | 106 | // signal. (Send URG and CHLD because they're ignored by default in the |
| 109 | 107 | // debugger, vs. USR1 or other named signals) |
| 110 | inline for ([_]i32{ std.posix.SIG.URG, std.posix.SIG.CHLD, 62, 94, 126 }) |test_signo| { | |
| 111 | if (test_signo >= std.posix.NSIG) continue; | |
| 112 | ||
| 108 | inline for ([_]std.posix.SIG{ .URG, .CHLD }) |test_signo| { | |
| 113 | 109 | S.expected_sig = test_signo; |
| 114 | S.seen_sig = NO_SIG; | |
| 110 | S.seen_sig = null; | |
| 115 | 111 | |
| 116 | 112 | const sa: std.posix.Sigaction = .{ |
| 117 | 113 | .handler = .{ .sigaction = &S.handler }, |
| ... | ... | @@ -135,14 +131,14 @@ fn test_sigset_bits() !void { |
| 135 | 131 | switch (std.posix.errno(rc)) { |
| 136 | 132 | .SUCCESS => { |
| 137 | 133 | // See that the signal is blocked, then unblocked |
| 138 | try std.testing.expectEqual(NO_SIG, S.seen_sig); | |
| 134 | try std.testing.expectEqual(null, S.seen_sig); | |
| 139 | 135 | std.posix.sigprocmask(std.posix.SIG.UNBLOCK, &block_one, null); |
| 140 | 136 | try std.testing.expectEqual(test_signo, S.seen_sig); |
| 141 | 137 | }, |
| 142 | 138 | .INVAL => { |
| 143 | 139 | // Signal won't get delviered. Just clean up. |
| 144 | 140 | std.posix.sigprocmask(std.posix.SIG.UNBLOCK, &block_one, null); |
| 145 | try std.testing.expectEqual(NO_SIG, S.seen_sig); | |
| 141 | try std.testing.expectEqual(null, S.seen_sig); | |
| 146 | 142 | }, |
| 147 | 143 | else => |errno| return std.posix.unexpectedErrno(errno), |
| 148 | 144 | } |