php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11023 exec does not wait for completion of cmd
Submitted: 2001-05-22 13:14 UTC Modified: 2002-01-12 06:47 UTC
From: terry at advertwizard dot com Assigned:
Status: Closed Package: Program Execution
PHP Version: 4.0.5 OS: slackware 7
Private report: No CVE-ID: None
 [2001-05-22 13:14 UTC] terry at advertwizard dot com
$cmd = "mv " . SITES_IMP . "site_* " . DB_UPDATES;
exec($cmd);

$arr = array();
$cmd = "ls " . DB_UPDATES . " site_* | wc -l";
exec($cmd,$arr);

i am of the impression that code proceeding an exec cmd will not execute until the exec is finished

in the above instance, the "ls" exec is executing before the "mv" exec has finished - when i know that 10 files have been moved, the "ls" exec returns 0 for a "wc -l", when running the code again it returns the number of files correctly - have placed sleeps between the commands and all works well

wondered if this is a bug in the exec cmd or my misunderstanding of its use

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-22 07:04 UTC] lobbin@php.net
Does this happen on 4.1.0?

R.
 [2002-01-12 06:47 UTC] lobbin@php.net
No feedback, closing.
 [2004-02-09 16:56 UTC] lars at erhardsen dot dk
I think, I have a similar problem.

The scenary is: Linux 2.4.22, Apache 2.0.48, PHP 4.3.4 on a Pentium 4, 2.4ghz, 512 mb ram

The page continues without the 'output' from exec thus leaving an incomplete page. If I press f5/refresh, some times it works, other times it does not work.

I have also placed sleeps between commands to ensure it works well.


My php config: 
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local --with-pdflib=/usr/local --with-mysql --with-config-file-path=/etc/apache2 --with-session --with-zlib-dir=/usr --with-png-dir=/usr/lib --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-tiff-dir=/usr --with-system-regex=yes --enable-debug=no --with-xml --with-imap-ssl=/usr/local/imap-2002d --enable-exif --with-openssl --with-gettext --enable-ftp --enable-sysvsem --enable-sysvshm --enable-calendar --enable-bcmath --enable-sockets --enable-track-vars --with-mcrypt --enable-gd-native-ttf --enable-mbstring --enable-gd-native-ttf

My Apache config:
./configure --enable-ssl --enable-rewrite --enable-so --enable-info --enable-suexec --with-suexec-caller=nobody --enable-dav  --enable-deflate
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC