1 / 8

Linux System Programing

Linux System Programing. Ex)6-8,9,10 2009243137 고이토 기요타카. Exec 함수. 프로세스의 메모리 공간을 수행 가능한 파일로 대체 새로운 프로세스를 생성시키기 위해 사용하는 시스템 콜 함수 execl , execv , execlp , execle. Ex6-8. 시스템 환경 변수 테이블 포인터 선언. Extern char ** envirin ; main( argc , argv ) Int argc ; char * argv ; { char **p;

whitby
Download Presentation

Linux System Programing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux System ProgramingLinux System Programing Ex)6-8,9,10 2009243137 고이토 기요타카

  2. Exec함수 • 프로세스의 메모리 공간을 수행 가능한 파일로 대체 • 새로운 프로세스를 생성시키기 위해 사용하는 시스템 콜 함수 • execl, execv, execlp, execle..

  3. Ex6-8 시스템 환경 변수 테이블 포인터 선언 Extern char **envirin; main(argc, argv) Intargc; char *argv; { char **p; int n; printf(“My input parameters(argv) are: \n”); for(n=0; n < argc; n++) printf(“ %2: ‘%s’\n”, n, argv[n]); printf(“\nMyenviroment variables are:\n”); for(p=environ; *p!=(char *) 0; P++) printf(“ %s\n”, *p); } 명령어 라인 인수를 모두 출력 시스템 환경 변수 모두 출력

  4. Ex6-8결과 화면

  5. Ex6-9 #include<stdio.h> main() { printf(“this is the orignal program\n”); execl(“./ex6-8”, ex6-8”, “parm1”, “parm2”, “parm3”,(char*)0); perror(“This line should never ger printed\n”); } Perror부분은 수행 되지 않고 execl( )호출에 의해 프로세스가 ex6-8로 대치.ex6-8이 실행을 종료하면 본래 프로그램으로 돌아가지 않고 프로세스가 종료된다.

  6. Ex6-9결과 화면

  7. Ex6-10 #include<stdio.h> main() { static char *nargv[] = { “ex6-8”, “parm1”, “parm2”, “parm3”, (char *)0}; printf(“this is the original porgram\n”); execv(“.\ex6-8”, nargv); Perror(“This line should never get printed\n”); } 기본적으로는 ex6-9과 마찬가지로 Perror부분은 수행 되지 않고 execv( )호출에 의해 프로세스가 ex6-8로 대치.ex6-8이 실행을 종료하면 본래 프로그램으로 돌아가지 않고 프로세스가 종료된다.

  8. Ex6-10결과 화면

More Related