My code is:
#!/usr/bin/python
import os
os.system('ls')
I converted it to C code using cython:
~ $ cython ostest.py
~ $ ls ostest*
ostest.c ostest.py
Then compiled C file using gcc:
~ $ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing \-I/usr/include/python2.7 -o ostest.so ostest.c
~ $ ls ostest*
ostest.c ostest.py ostest.so
And when I tried to execute the file, its giving error:
~ $ ./ostest.so
Segmentation fault
I checked the file permissions:
~ $ ls -l ostest.so
-rwxr-xr-x
The python code I mentioned above is just a sample. I tried doing the same with other python programs I have written. For all of them, I'm getting the same error.
How to solve this?