| 1 | package SPVM::Sys::Signal; | ||
| 2 | |||
| 3 | 1; | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | SPVM::Sys::Signal - Signal System Calls | ||
| 8 | |||
| 9 | =head1 Description | ||
| 10 | |||
| 11 | Sys::Signal class in L<SPVM> manipulate system calls for signals. | ||
| 12 | |||
| 13 | =head1 Usage | ||
| 14 | |||
| 15 | use Sys::Signal; | ||
| 16 | use Sys::Signal::Constant as SIGNAL; | ||
| 17 | |||
| 18 | Sys::Signal->kill($process_id, SIGNAL->SIGINT); | ||
| 19 | |||
| 20 | Sys::Signal->signal(SIGNAL->SIGTERM, Sys::Signal->SIG_IGN); | ||
| 21 | |||
| 22 | =head1 Class Methods | ||
| 23 | |||
| 24 | =head2 raise | ||
| 25 | |||
| 26 | C<static method raise : int ($sig : int)> | ||
| 27 | |||
| 28 | Calls the L<raise|https://linux.die.net/man/3/raise> function and returns its return value. | ||
| 29 | |||
| 30 | See L<Sys::Signal::Constant|SPVM::Sys::Signal::Constant> about constant values given to $sig. | ||
| 31 | |||
| 32 | Exceptions: | ||
| 33 | |||
| 34 | If the raise function failed, an exception is thrown with C<eval_error_id> set to the basic type ID of the L<Error::System|SPVM::Error::System> class. | ||
| 35 | |||
| 36 | =head2 signal | ||
| 37 | |||
| 38 | C<static method signal : L<Sys::Signal::Handler|SPVM::Sys::Signal::Handler> ($signum : int, $handler : L<Sys::Signal::Handler|SPVM::Sys::Signal::Handler>);> | ||
| 39 | |||
| 40 | Calls L<signal|https://linux.die.net/man/2/signal> function and creates a signal handler object with its pointer set to the function's return value, and returns it. | ||
| 41 | |||
| 42 | $handler can be L</"SIG_DFL"> and L</"SIG_IGN">. | ||
| 43 | |||
| 44 | See L<Sys::Signal::Constant|SPVM::Sys::Signal::Constant> about constant values given to $sig. | ||
| 45 | |||
| 46 | Exceptions: | ||
| 47 | |||
| 48 | $handler must be defined. Otherwise an exception is thrown. | ||
| 49 | |||
| 50 | If the signal function failed, an exception is thrown with C<eval_error_id> set to the basic type ID of the L<Error::System|SPVM::Error::System> class. | ||
| 51 | |||
| 52 | =head2 kill | ||
| 53 | |||
| 54 | C<static method kill : int ($pid : int, $sig : int)> | ||
| 55 | |||
| 56 | Calls the L<kill|https://linux.die.net/man/2/kill> function and returns its return value. | ||
| 57 | |||
| 58 | See L<Sys::Signal::Constant|SPVM::Sys::Signal::Constant> about constant values given to $sig. | ||
| 59 | |||
| 60 | Exceptions: | ||
| 61 | |||
| 62 | If the kill function failed, an exception is thrown with C<eval_error_id> set to the basic type ID of the L<Error::System|SPVM::Error::System> class. | ||
| 63 | |||
| 64 | In Windows the following excetpion is thrown. kill is not supported in this system(defined(_WIN32)). | ||
| 65 | |||
| 66 | =head2 alarm | ||
| 67 | |||
| 68 | C<static method alarm : int ($seconds : int)> | ||
| 69 | |||
| 70 | Calls the L<alarm|https://linux.die.net/man/2/alarm> function and returns its return value. | ||
| 71 | |||
| 72 | Exceptions: | ||
| 73 | |||
| 74 | If the alarm function failed, an exception is thrown with C<eval_error_id> set to the basic type ID of the L<Error::System|SPVM::Error::System> class. | ||
| 75 | |||
| 76 | In Windows the following excetpion is thrown. alarm is not supported in this system(defined(_WIN32)). | ||
| 77 | |||
| 78 | =head2 ualarm | ||
| 79 | |||
| 80 | C<static method ualarm : int ($usecs : int, $interval : int)> | ||
| 81 | |||
| 82 | Calls the L<ualarm|https://linux.die.net/man/3/ualarm> function and returns its return value. | ||
| 83 | |||
| 84 | Exceptions: | ||
| 85 | |||
| 86 | In Windows the following excetpion is thrown. ualarm is not supported in this system(defined(_WIN32)). | ||
| 87 | |||
| 88 | =head2 SIG_DFL | ||
| 89 | |||
| 90 | C<static method SIG_DFL : L<Sys::Signal::Handler|SPVM::Sys::Signal::Handler> ();> | ||
| 91 | |||
| 92 | Creates a new signal handler that represents C<SIG_DFL>. | ||
| 93 | |||
| 94 | =head2 SIG_IGN | ||
| 95 | |||
| 96 | C<static method SIG_IGN : L<Sys::Signal::Handler|SPVM::Sys::Signal::Handler> ();> | ||
| 97 | |||
| 98 | Creates a new signal handler that represents C<SIG_IGN>. | ||
| 99 | |||
| 100 | =head1 See Also | ||
| 101 | |||
| 102 | =over 2 | ||
| 103 | |||
| 104 | =item * L<Sys|SPVM::Sys> | ||
| 105 | |||
| 106 | =back | ||
| 107 | |||
| 108 | =head1 Copyright & License | ||
| 109 | |||
| 110 | Copyright (c) 2023 Yuki Kimoto | ||
| 111 | |||
| 112 | MIT License | ||
| 113 |