zoukankan      html  css  js  c++  java
  • Forking and Executing the Process

    To create a process using BSD system calls, your process must call the fork system call. The fork call creates a logical copy of your process, then returns the ID of the new process to your process. Both the original process and the new process continue executing from the call to fork; the only difference is that fork returns the ID of the new process to the original process and zero to the new process. (The fork function returns -1 to the original process and sets errno to a specific error value if the new process could not be created.)

    To run a different executable, your process must call the execve system call with a pathname specifying the location of the alternate executable. The execve call replaces the program currently in memory with a different executable file.

    A Mach-O executable file contains a header consisting of a set of load commands. For programs that use shared libraries or frameworks, one of these commands specifies the location of the linker to be used to load the program. If you use Xcode, this is always /usr/lib/dyld, the standard Mac OS X dynamic linker.

    When you call the execve routine, the kernel first loads the specified program file and examines the mach_header structure at the start of the file. The kernel verifies that the file appear to be a valid Mach-O file and interprets the load commands stored in the header. The kernel then loads the dynamic linker specified by the load commands into memory and executes the dynamic linker on the program file.

    The dynamic linker loads all the shared libraries that the main program links against (the dependent libraries) and binds enough of the symbols to start the program. It then calls the entry point function. At build time, the static linker adds the standard entry point function to the main executable file from the object file /usr/lib/crt1.o. This function sets up the runtime environment state for the kernel and calls static initializers for C++ objects, initializes the Objective-C runtime, and then calls the program’s main function. 

    http://www.cs.miami.edu/home/burt/learning/Csc521.091/docs/MachOTopics.pdf

  • 相关阅读:
    Vue应用框架整合与实战--Vue技术生态圈篇
    SpringBoot2.0之八 多数据源配置
    SpringBoot2.0之七 实现页面和后台代码的热部署
    SpringBoot2.0之六 多环境配置
    SpringBoot2.0之五 优雅整合SpringBoot2.0+MyBatis+druid+PageHelper
    SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍
    @getMapping与@postMapping
    701搜商家电话直通 网络黄页完成“终极使命”
    根据经纬度计算距离
    微网站
  • 原文地址:https://www.cnblogs.com/feng9exe/p/12457062.html
Copyright © 2011-2022 走看看