Question: Why is this code not executing the program? The file path is correct. I'm using fork() to create child processes and execv() to get those

Why is this code not executing the program? The file path is correct. I'm using fork() to create child processes and execv() to get those child processes to run unix commands successfully in the same program.

import os filepath = '/Users/my_name/Desktop/school/Spring23/OS/os_code/file_name.py' 
pid = os.fork() if pid == 0: os.execv('/usr/local/bin/python3', ['python3', filepath, '100000']) When I enter python3 '/Users/my_name/Desktop/school/Spring23/OS/os_code/file_name.py' 100000 into my shell I get the correct output. 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!