subprocess to C program
Grant Edwards
grante at visi.com
Sat Dec 13 20:51:23 EST 2008
More information about the Python-list mailing list
Sat Dec 13 20:51:23 EST 2008
- Previous message (by thread): subprocess to C program
- Next message (by thread): subprocess to C program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2008-12-14, MRAB <google at mrabarnett.plus.com> wrote: >> I am writing a C process and I want to read data from a file that I >> write to in Python. I'm creating a pipe in Python, passing it to the >> C process, and calling '_read'. It gives me error 9, bad file number. >> >> Python code: >> >> import subprocess as s, os >> r, w= os.pipe( ) >> os.write( w, 'abcdefghij\n' ) >> a= s.Popen( [ r'C:\Documents and Settings\usr\Desktop\working >> \try_start', '%i'%r, '%i'%w ] ) >> >> C code: >> >> char buf[ 16 ]; >> memset( buf, 0, 16 ); >> int readfd= atoi( argv[ 1 ] ); >> int ct= _read( readfd, buf, 15 ); >> printf( "\n\n'_read %i %i %i': %s\n", ct, readfd, errno, buf ); >> >> Output: >> >> '_read -1 3 9' >> >> meaning that 'ct' is -1, 'readfd' is 3, and 'errno' is 9. I want 'ct' >> to be 11 at this point. Thanks in advance. >> > It looks like the ids aren't system global. They certainly aren't in Unix: Their a property of the process. -- Grant
- Previous message (by thread): subprocess to C program
- Next message (by thread): subprocess to C program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list