Find Jobs
Hire Freelancers

C programming

$5-10 USD

已完成
已发布大约 21 年前

$5-10 USD

货到付款
Introduction: The exec system call overlays a new program into a process. The fork and exec combination is used very frequently in UNIX to spawn a new process and to overlay a new program. A common example is trying a shell command at a shell prompt. The shell forks a new process which starts with a shell image, then makes an exec call to overlay the shell image the shell command. Complete the following skeleton C program for spawning a process and starting a new program. /*This program reads a command line from the terminal and executes it*/ #include/*declare functionm protocols here*/ /*the main fuction is given as follows main() { char*line [132]; char*command; char**argv; int pid; while(1) { if(gets(line)==0)exit(0); if(strlen(line)==0)continue; parse_command(line, command, &argv); pid = start_command(command, argv); if(pid>0)wait(0); } } /*Your job is to complete two functions: parse_command, start_command, and child*/ /*1. write a function to parse command*/ void parse_command (char[] line,char*command, char**argv) { } /*2. complete the start_command function*/ int start_command(char*command, char**argv) { int pid; /*return value of fork call //Create child process ....... if(pid==0){ /* invoke the child function here*/ } else if (pid<0){ /*print out fork error message*/ } return pid; } /*3. Complete child function*/ void child(char*command, char**argv){ int status; /*status will store the return value of an execvp system call*/ /*EXEC new command in child process by invoking execvp system call*/ ...... /*If exec was successful, this code will not be executed.*/ if(status<0){ /*print error message: a wrong command*/ } exit(0); } ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bi request. 3) Complete ownership and distribution copyrights to all work purchased. ## Platform C programming only
项目 ID: 2907729

关于此项目

6提案
远程项目
活跃21 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
See private message.
$5 USD 在14天之内
4.9 (79条评论)
4.7
4.7
6威客以平均价$7 USD来参与此工作竞价
用户头像
See private message.
$8.50 USD 在14天之内
4.9 (175条评论)
5.9
5.9
用户头像
See private message.
$7.65 USD 在14天之内
4.9 (68条评论)
4.8
4.8
用户头像
See private message.
$6.80 USD 在14天之内
4.8 (14条评论)
4.5
4.5
用户头像
See private message.
$5.95 USD 在14天之内
4.9 (10条评论)
2.5
2.5
用户头像
See private message.
$8.50 USD 在14天之内
5.0 (4条评论)
1.3
1.3

关于客户

UNITED STATES的国旗
United States
5.0
1
会员自1月 29, 2003起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。