Yesterday, the Network Storage System developed by the lab encountered a BUG. [Problem description] php uses the exec function to call the Linux Command servicesmbrestart (restart the Samba Service). After normal restart, the exec function returns the status code 0 immediately, however, after the underlying layer was restarted normally yesterday, the exec function was delayed, causing program execution to get stuck here.
Yesterday, the Network Storage System developed by the lab encountered a BUG. [Problem description] php uses the exec function to call the Linux Command service smb restart (restart the Samba service). After normal restart, the exec function returns the status code 0 immediately, however, after the underlying layer was restarted normally yesterday, the exec function was delayed, causing program execution to get stuck here.
Yesterday, the Network Storage System developed by the lab encountered a BUG.
[Problem description]
Php uses the exec function to call the Linux Command "service smb restart" (restart Samba service). After normal restart, the exec function returns the status code 0 immediately, however, after the underlying layer was restarted normally yesterday, the exec function was delayed, causing program execution to get stuck here.
[Solution]
(1) At first, I was wondering what caused the samba service to fail to be restarted. After further experiments, we found that through our network storage system, the samba service can be shut down normally, however, the enabling and restarting operations cannot be performed normally. In addition, the command to enable and restart the service can be executed and returned normally on the underlying Linux console. Based on the above experiment, I guess the problem may be related to permissions related to php and samba services. Later, I checked samba configuration files, directory permissions, and openldap, a samba-related user permission management tool. No obvious problems were found (excluding omissions ).
(2) Later, I thought of the History CT script that I used to monitor the execution time of a command and forcibly terminate it after the timeout. Encapsulate the samba service restart command using the reset CT script and set the timeout. Then, run the script separately to forcibly return the result after the specified timeout, however, our network storage system still cannot return normally when executing this script.
(3) Finally, I started with the exec function. After investigation, I finally switched to the proc_open and proc_close functions (to open and close a process channel) php code: proc_close (proc_open ("service smb restart", $ output, $ ret ));
At this point, the BUG of yesterday has been bypassed, but I still don't quite understand why this problem occurs. If a friend has encountered a similar situation, please share your experience ~