php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78700 support posix strsignal(int signo)
Submitted: 2019-10-20 09:56 UTC Modified: 2019-10-20 10:54 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: divinity76+spam at gmail dot com Assigned:
Status: Open Package: PCNTL related
PHP Version: Next Minor Version OS: POSIX
Private report: No CVE-ID: None
 [2019-10-20 09:56 UTC] divinity76+spam at gmail dot com
Description:
------------
Posix has a function called strsignal(), since at least POSIX.1-2008, docs can be found here https://pubs.opengroup.org/onlinepubs/9699919799/functions/strsignal.html 

but the TL;DR is that it converts a signal to it's signal name (like in Linux, signal 15 is SIGTERM, and it converts int(15) to string("SIGTERM"))

would be nice if the posix extension could add support for it.


a naive-ish userland implementation can be found at https://stackoverflow.com/a/58471626/1067003
 (i don't know if the userland implementation is error-free, and it does not use the posix strsignal() function, but at least it appears to work)

Test script:
---------------
<?php

var_dump(posix_strsignal(SIGTERM));

Expected result:
----------------
string(7) "SIGTERM"

Actual result:
--------------
PHP Fatal error:  Uncaught Error: Call to undefined function posix_strsignal() in /foo.php:3
Stack trace:
#0 {main}
  thrown in /jail/home/foo.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-20 10:54 UTC] requinix@php.net
-Package: POSIX related +Package: PCNTL related
 [2019-10-20 10:54 UTC] requinix@php.net
It should probably go with the pcntl functions, since it's related to signal handling.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC