import os
for pid in ['4155','4358','4359','4360','4362','4363','11435','12296','6635','6650','2004','3500']:
    try:
        st=open('/proc/'+pid+'/stat').read()
        name=st.split('(')[1].split(')')[0]
        f=st.split(')')[1].split()
        ppid=f[1]
        print(pid, name, 'PPID', ppid, 'state', f[0])
    except Exception as e:
        print(pid, e)
print('--- apache2 env 4155 ---')
try:
    print(open('/proc/4155/environ','rb').read().replace(b'\x00',b'\n').decode(errors='replace'))
except Exception as e: print(e)
print('--- apache2 cwd ---')
try: print(os.readlink('/proc/4155/cwd'))
except Exception as e: print(e)
print('--- httpd 11435 env ---')
try:
    print(open('/proc/11435/environ','rb').read().replace(b'\x00',b'\n').decode(errors='replace'))
except Exception as e: print(e)
