<?php
require __DIR__.'/common.php';$pid=(int)($argv[1]??0);$port=$lane==='B'?18931:18932;$parent=$lane==='B'?10001:112175;if($pid<1||strpos((string)@file_get_contents('/proc/'.$pid.'/cmdline'),__DIR__.'/index.php')===false)throw new RuntimeException('Exact own lists worker');$n=0;foreach(json_decode(file_get_contents(__DIR__.'/source-lock.json'),true)as $f=>$sha){if(hash_file('sha256',__DIR__.'/source/application/'.$f)!==$sha)throw new RuntimeException('Source final SHA');$n++;}$deps=[];foreach(['thinkphp/library/think/db/connector/Mysql.php','thinkphp/library/think/db/builder/Mysql.php','thinkphp/library/think/db/Connection.php','thinkphp/library/think/db/Query.php','external_stubs.php']as $f)$deps[$f]=hash_file('sha256',$root.'/'.$f);$save('source-provenance.json',['source_php_files'=>$n,'source_lock_sha256'=>hash_file('sha256',__DIR__.'/source-lock.json'),'dependencies'=>$deps,'own_worker_pid'=>$pid,'own_worker_cmdline'=>(string)file_get_contents('/proc/'.$pid.'/cmdline')]);posix_kill($pid,SIGTERM);usleep(200000);$socket=@fsockopen('127.0.0.1',$port,$n,$e,1);$closed=$socket===false;if($socket)fclose($socket);$apple=[];foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__,FilesystemIterator::SKIP_DOTS))as $f)if(strpos($f->getFilename(),'._')===0)$apple[]=$f->getPathname();$out=['own_worker_absent'=>(string)@file_get_contents('/proc/'.$pid.'/cmdline')==='','own_port_closed'=>$closed,'original_parent_present'=>is_file('/proc/'.$parent.'/cmdline'),'request_absent'=>!is_file(__DIR__.'/private/request.json'),'cache_absent'=>!is_dir(__DIR__.'/cache'),'AppleDouble'=>$apple];$save('resource-check.json',$out);echo json_encode($out),"\n";
