- time_t now = time ((time_t *) 0);
- char *str = (char *) ctime (&now);
- char *nl = (char *) strchr (str, '\n');
- if (nl) *nl = 0; /* take off that dang newline */
- return str;
+ if (in_signal_handler_p)
+ {
+ /* Turns out that ctime() and even localtime_r() call malloc() on Linux!
+ So we can't call them from inside SIGCHLD. WTF.
+ */
+ static char buf[30];
+ strcpy (buf, "... ... .. signal ....");
+ return buf;
+ }
+ else
+ {
+ time_t now = time ((time_t *) 0);
+ char *str = (char *) ctime (&now);
+ char *nl = (char *) strchr (str, '\n');
+ if (nl) *nl = 0; /* take off that dang newline */
+ return str;
+ }