View Issue Details

IDProjectCategoryView StatusLast Update
0000728Apache 2.x Bugpublic2021-07-25 11:31
ReporteremaxAssigned ToSteven Levine 
PrioritynormalSeverityminorReproducibilitysometimes
Status assignedResolutionopen 
PlatformSupermicro Intel Xeon 4 coreOSeCS-AOSOS Version2.1+ANdrv-pack
Product Version2.4.x 
Target VersionFixed in Version 
Summary0000728: Apache 2.4.48 sometimes give permission denied on PID file while exiting
Descriptionfrom apache error log:

[Fri Mar 19 10:35:11.700000 2021] [core:error] [pid 2196:tid 1] (13)Permission denied: AH00095: failed to remove PID file X:/apache2/logs/httpd.pid

Server Version: Apache/2.4.46 (OS/2) OpenSSL/1.1.1j PHP/5.6.40
Server Built: Feb 28 2021 07:53:23
Server loaded APR Version: 1.7.0
Compiled with APR Version: 1.7.0
Server loaded APU Version: 1.6.1
Compiled with APU Version: 1.6.1
Module Magic Number: 20120211:93
Steps To Reproducen/a
Additional InformationTicket originally opened for 2.4.46.
Issue persists with
Server Version: Apache/2.4.48 (OS/2) OpenSSL/1.1.1k PHP/5.6.40
Server MPM: mpmt_os2
Server Built: Jun 6 2021 15:51:55

TagsNo tags attached.

Activities

emax

2021-05-31 21:33

reporter   ~0003703

Hi all,

this issue of PID file don't get removed on exit is causing some issues to my scripts

should be possible to fix this?

thanks a lot

bye

massimo

psmedley

2021-06-06 15:33

administrator   ~0003714

How are you closing apache2? using go.exe or something similar?

emax

2021-06-07 02:34

reporter   ~0003715

myfile='d:\apache\logs\httpd.pid'
a=LINEIN(myfile)
'@go -k 'a
call SysSleep 2
'@go -k 'a

Steven Levine

2021-07-02 06:51

manager   ~0003776

Can this ticket be closed? Have you switched to apache_kill -TERM?

emax

2021-07-05 03:25

reporter   ~0003778

hi,

what's apache_kill - TERM?

Steven Levine

2021-07-05 07:20

manager   ~0003779

This is Brian Havard's kill.exe from

  http://silk.apana.org.au/pub/apache/apache_restart.zip

emax

2021-07-05 17:46

reporter   ~0003780

talking about the util, kill function works

restart function do not work

in the next days i will say if i see again the error:

[core:error] [pid 2196:tid 1] (13)Permission denied: AH00095: failed to remove PID file X:/apache2/logs/httpd.pid

emax

2021-07-05 18:11

reporter   ~0003781

using this tool do not fix the issue:

[Mon Jul 05 10:40:15.029000 2021] [core:error] [pid 604:tid 1] (13)Permission denied: AH00095: failed to remove PID file X:/apache/logs/httpd.pid

Steven Levine

2021-07-07 03:53

manager   ~0003782

I should not have to ask this question, but...

Using this tool how?

In case the above question was not clear, exactly what command line did you use?

Steven Levine

2021-07-07 03:57

manager   ~0003783

Also, this is a second and final reminder, unless you update the ticket summary to match the httpd version you are running I will be unassigning myself from this ticket.

emax

2021-07-07 17:54

reporter   ~0003784

answer to note 3782:

pid = linein("X:\apache\logs\httpd.pid")
'kill.exe -TERM 'pid

answer to note 3783:

i'd like to, but i don't know how to update that "summary"

the build i'm running is this one:

Server Version: Apache/2.4.48 (OS/2) OpenSSL/1.1.1k PHP/5.6.40
Server MPM: mpmt_os2
Server Built: Jun 6 2021 15:51:55

Steven Levine

2021-07-10 09:47

manager   ~0003790

Remember your REXX. I'm pretty sure you missed a line of code. You need to close the pid file if you want httpd to be able to delete the file.

Try:

 pid = linein("X:\apache\logs\httpd.pid")
 call close "X:\apache\logs\httpd.pid"
 'kill.exe -TERM' pid

emax

2021-07-10 19:11

reporter   ~0003793

9 +++ Call close 'x:\apache\logs\httpd.pid';
REX0043: Error 43 running x:\stop_apache.cmd, line 9: Routine not found

Steven Levine

2021-07-10 23:53

manager   ~0003797

My bad. I need to remember to tell you exactly what you need to do:

 call stream 'C' 'close' "X:\apache\logs\httpd.pid"

emax

2021-07-11 01:27

reporter   ~0003801

updated the script, but...

[Sat Jul 10 17:55:24.599000 2021] [core:error] [pid 3840:tid 1] (13)Permission denied: AH00095: failed to remove PID file X:/apache/logs/httpd.pid

see my \apache\logs dir...

10/07/21 17:55 6 0 a--- httpd.pid
5/07/21 10:14 5 0 a--- httpd.pid.RukG7D
8/07/21 14:09 6 0 a--- httpd.pid.tnOLQd

i believe it try to create a temp file, since it's unable to delete it

Steven Levine

2021-07-11 01:44

manager   ~0003802

FWIW, the temp files are old. I don't recall any code in httpd to create such a temp file. Perhaps, it is one of your scripts?

Another thought is that perhaps another of your scripts is leaving the file open.

From the command line:

  psfiles | find "HTTPD.PID"

will show which processes have the file open.

I will note that apache does not keep the file open after it is created:

[d:\tmp]apachectl start
start "Apache server 2.4" /min /c httpd -d..
Apache server started and running as Pid 2164(874)

[d:\tmp]psfiles | find "HTTPD.PID"

Some applications do keep their PiD file open, but not httpd. For example ZTB keeps its PID file open

[d:\tmp]psfiles | find "PID"
0865 0003 0237 0005 00000000 00000021 00000004 01fe 0020 E:\TMP\ZTMP000\ZTB.PID
0866 0003 0237 0005 00000000 00000021 00000004 01fe 0020 E:\TMP\ZTMP000\ZTB.PID
0856 0003 0237 0005 00000000 00000021 00000004 01fe 0020 E:\TMP\ZTMP000\ZTB.PID
07f7 0003 0237 0005 00000000 00000021 00000004 01fe 0020 E:\TMP\ZTMP000\ZTB.PID
07f5 0003 0237 0005 00000000 00000021 00000004 01fe 0020 E:\TMP\ZTMP000\ZTB.PID

emax

2021-07-12 05:22

reporter   ~0003805

FWIW, the temp files are old. I don't recall any code in httpd to create such a temp file. Perhaps, it is one of your scripts?

no, it's simply impossibile
my scripts aren't malicious AI :D

massimo

Steven Levine

2021-07-14 01:36

manager   ~0003807

OK, I found the code that creates the temporary pid file. I'd never had a need to look for it previously, so it makes sense that I might not recall that it existed. It's still your non- malicious (<g>) script or scripts that are at fault.

When creating the pid file, httpd creates the file with a temporary name and then renames this file to httpd.pid. If httpd.pid is left open by one of your scripts, the rename will fail and httpd will log the error. You should be able to find the error message in the log file. Look for "Failed creating pid file."

When one of your scripts reads the pid file, it must close the file as soon as possible after reading it.

There is still a very small time window where the rename could fail. Your script might have the pid file open and a new httpd process might be trying to rename the temporary pid file at exactly the same time. However, on a single core system this situation is unlikely to occur.

emax

2021-07-14 01:48

reporter   ~0003808

@X:
@cd X:\apache
@SET LIBPATHSTRICT=T
@set beginlibpath=X:\apache\bin;X:\apache\modules;
@erase X:\restartapache.lck /N 1>NUL 2>NUL
@start "apache.cmd" /N X:\apache\bin\httpd -d X:\apache 2>>X:\logs\apache_errorlog

emax

2021-07-14 02:04

reporter   ~0003811

about the "Failed creating pid file." message i don't find it in the logs

emax

2021-07-14 20:50

reporter   ~0003814

when i stop apache, i get:

kill.exe -TERM 6319
SYS0032: The process cannot access the file because it is being used
by another process.
Error occurred while processing: X:\apache\logs\httpd.pid.

this may help?

thanks

Steven Levine

2021-07-15 14:14

manager   ~0003817

As I mentioned in a previous comment, you need to check which process has httpd.pid open. I recommend adding:

 'psfiles | find "HTTPD.PID"'

to your kill script before the kill is issued.

emax

2021-07-15 23:46

reporter   ~0003820

[Thu Jul 15 15:20:54.260000 2021] [core:error] [pid 1699:tid 1] (13)Permission denied: AH00095: failed to remove PID file X:/apache/logs/httpd.pid
[Thu Jul 15 15:20:54.260000 2021] [mpm_mpmt_os2:notice] [pid 1699:tid 1] AH00201: caught SIGTERM, shutting down
[Thu Jul 15 15:20:54.205000 2021] [mpm_mpmt_os2:error] [pid 2637:tid 1] (70007)The timeout specified has expired: AH00194: apr_socket_accept

Killed by SIGSEGV
pid=0x0a4d ppid=0x0010 tid=0x0003 slot=0x009e pri=0x0200 mc=0x0001 ps=0x0016
D:\APACHE\BIN\HTTPD.EXE
LIBCN0 ffffffff:ffffffff
cs:eip=22ff8220:23003e23 ss:esp=0000:00000001 ebp=00000053
 ds=0000 es=0000 fs=0000 gs=0000 efl=0243f7e0
eax=0243f88c ebx=1ffc9d7c ecx=0243f8a0 edx=0243f8c4 edi=00000000 esi=0243ffd4
Creating 0A4D_03.TRP
[Thu Jul 15 15:20:58.686000 2021] [mpm_mpmt_os2:error] [pid 2805:tid 1] AH00200: DosGetNamedSharedMem returned 0
[Thu Jul 15 15:20:58.686000 2021] [core:warn] [pid 2805:tid 1] AH00098: pid file X:/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Jul 15 15:20:58.688000 2021] [core:error] [pid 2805:tid 1] (OS 32)SYS0032: The process cannot access the file because it is being used by another process. : AH10231: httpd.exe: Failed creating pid file X:/apache/logs/httpd.pid.NicCck

i will take a look to the scripts, but the same scripts were not giving this issue with apache 2.2.x

0A4D_03.TRP (27,584 bytes)

emax

2021-07-16 02:57

reporter   ~0003824

i'm sorry this exceptQ dump lack LIBCN symbolics, i've now installed the needed .DBG

Issue History

Date Modified Username Field Change
2021-03-21 03:04 emax New Issue
2021-05-31 21:33 emax Note Added: 0003703
2021-06-06 15:33 psmedley Note Added: 0003714
2021-06-07 02:34 emax Note Added: 0003715
2021-07-02 06:51 Steven Levine Assigned To => Steven Levine
2021-07-02 06:51 Steven Levine Status new => feedback
2021-07-02 06:51 Steven Levine Note Added: 0003776
2021-07-05 03:25 emax Note Added: 0003778
2021-07-05 03:25 emax Status feedback => assigned
2021-07-05 07:20 Steven Levine Note Added: 0003779
2021-07-05 17:46 emax Note Added: 0003780
2021-07-05 18:11 emax Note Added: 0003781
2021-07-07 03:53 Steven Levine Status assigned => feedback
2021-07-07 03:53 Steven Levine Note Added: 0003782
2021-07-07 03:57 Steven Levine Note Added: 0003783
2021-07-07 17:54 emax Note Added: 0003784
2021-07-07 17:54 emax Status feedback => assigned
2021-07-10 09:44 Steven Levine Summary Apache 2.4.46 sometimes give permission denied on PID file while exiting => Apache 2.4.48 sometimes give permission denied on PID file while exiting
2021-07-10 09:44 Steven Levine Additional Information Updated View Revisions
2021-07-10 09:47 Steven Levine Status assigned => feedback
2021-07-10 09:47 Steven Levine Note Added: 0003790
2021-07-10 19:11 emax Note Added: 0003793
2021-07-10 19:11 emax Status feedback => assigned
2021-07-10 23:53 Steven Levine Status assigned => feedback
2021-07-10 23:53 Steven Levine Note Added: 0003797
2021-07-11 01:27 emax Note Added: 0003801
2021-07-11 01:27 emax Status feedback => assigned
2021-07-11 01:44 Steven Levine Status assigned => feedback
2021-07-11 01:44 Steven Levine Note Added: 0003802
2021-07-12 05:22 emax Note Added: 0003805
2021-07-12 05:22 emax Status feedback => assigned
2021-07-14 01:36 Steven Levine Status assigned => feedback
2021-07-14 01:36 Steven Levine Note Added: 0003807
2021-07-14 01:48 emax Note Added: 0003808
2021-07-14 01:48 emax Status feedback => assigned
2021-07-14 02:04 emax Note Added: 0003811
2021-07-14 20:50 emax Note Added: 0003814
2021-07-15 14:14 Steven Levine Status assigned => feedback
2021-07-15 14:14 Steven Levine Note Added: 0003817
2021-07-15 23:46 emax File Added: 0A4D_03.TRP
2021-07-15 23:46 emax Note Added: 0003820
2021-07-15 23:46 emax Status feedback => assigned
2021-07-16 02:57 emax Note Added: 0003824