#35894 [Opn->Fbk]: php-imap doesn't trap USR2 when mailbox is locked

From: Date: Wed, 04 Jan 2006 14:47:16 +0000
Subject: #35894 [Opn->Fbk]: php-imap doesn't trap USR2 when mailbox is locked
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91463@lists.php.net to get a copy of this message
 ID:               35894
 Updated by:       tony2001@php.net
 Reported By:      jik at kamens dot brookline dot ma dot us
-Status:           Open
+Status:           Feedback
 Bug Type:         IMAP related
 Operating System: Linux
 PHP Version:      5.1.1
 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.




Previous Comments:
------------------------------------------------------------------------

[2006-01-04 15:40:29] jik at kamens dot brookline dot ma dot us

Description:
------------
The imap c-client has code in it to send a "kiss of death" SIGUSR2 to
another process that has a mailbox locked, to cause that process to
give up the lock if it no longer needs it.  Anything which uses
c-client is supposed to define a singla handler for SIGUSR2 to catch
the signal and at minimum ignore it if the client doesn't want to
relinquish the lock.  If it doesn't do this, then the SIGUSR2 causes
the process to die, and then the other process, which sent the signal,
claims the lock.

It appears that PHP's imap support doesn't define a SIGUSR2 handler,
which means that if (a) imap_open is used to open a local file and (b)
another process on the same machine happens to use c-client to open the
same file at around the same time, the first process will die silently
because of the SIGUSR2.

To fix this, imap_open needs to define a SIGUSR2 handler to catch and
ignore the signal while it's got the mailbox locked.

Reproduce code:
---------------
Put this script in a file and run it with one argument, the name of a
non-empty local mailbox, twice at the same time, e.g. (from bash) "php
/tmp/imap_open.php /var/mail/jik & php /tmp/imap_open.php
/var/mail/jik".  It may not fail every time, but at least some of the
times you do this, okne of the two php processes will print an error
and exit because of the USR2 signal.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35894&edit=1


Thread (45 messages)

« previous php.bugs (#91463) next »