init

android的init过程分析

别说谁变了你拦得住时间么 提交于 2020-02-29 08:36:32
前言 Android系统是运作在linux kernal上的,因此它的启动过程也遵循linux的启动过程,当linux内核启动之后,运行的第一个进程是init,这个进程是一个守护进程,它的生命周期贯穿整个linux 内核运行的始终, linux中所有其他的进程的共同始祖均为init进程。当然为了启动并运行整个android系统,google实现了自己的init进程,下面主要分析init进程都做了些什么? 1.首先,init是一个守护进程,为了防止init的子进程成为僵尸进程(zombie process),需要init在子进程在结束时获取子进程的结束码,通过结束码将程序表中的子进程移除,防止成为僵尸进程的子进程占用程序表的空间,当程序表的空间达到上限时,则系统就不能再启动新的进程了,那么就会引起很严重的系统问题。 在linux当中,父程序是通过捕捉SIGCHLD信号来得知子进程结束的情况的;由于系统默认在子进程暂停时也会发送信号SIGCHLD,init需要忽略子进程在暂停时发出的SIGCHLD信号,因此将act.sa_flags 置为SA_NOCLDSTOP,该标志位的含义是就是要求系统在子进程暂停时不发送SIGCHLD信号。具体的代码如下所示: struct sigaction act; ……………… act.sa_handler = sigchld_handler; act

Android系统启动-Init篇

扶醉桌前 提交于 2020-02-26 09:38:40
copy from : http://gityuan.com/2016/02/05/android-init/ 基于Android 6.0的源码剖析, 分析Android启动过程进程号为1的init进程的工作内容 system/core/init/ - init.cpp - init_parser.cpp - signal_handler.cpp 一、概述 init进程是Linux系统中用户空间的第一个进程,进程号固定为1。Kernel启动后,在用户空间启动init进程,并调用init中的main()方法执行init进程的职责。对于init进程的功能分为4部分: 解析并运行所有的init.rc相关文件 根据rc文件,生成相应的设备驱动节点 处理子进程的终止(signal方式) 提供属性服务的功能 接下来从main()方法说起。 1.1 main [-> init.cpp] static int epoll_fd = -1; int main(int argc, char** argv) { ... //设置文件属性0777 umask(0); //初始化内核log,位于节点/dev/kmsg【见小节1.2】 klog_init(); //设置输出的log级别 klog_set_level(KLOG_NOTICE_LEVEL); //创建一块共享的内存空间,用于属性服务【见小节5.1

小程序 之使用HMACSHA1算法加密报文

狂风中的少年 提交于 2020-02-23 15:18:29
首先说说我们前端常用的加密技术, 我们常用的加密技术有:如MD5加密,base64加密 今天要说的是HMACSHA1加密技术 先介绍下什么是SHA1算法, 安全哈希算法(Secure Hash Algorithm)主要适用于数字签名标准 (Digital Signature Standard DSS)里面定义的数字签名算法(Digital Signature Algorithm DSA)。对于长度小于2^64位的消息,SHA1会产生一个160位的消息摘要。当接收到消息的时候,这个消息摘要可以用来验证数据的完整性。在传输的过程中,数据很可能会发生变化,那么这时候就会产生不同的消息摘要。 SHA1有如下特性:不可以从消息摘要中复原信息;两个不同的消息不会产生同样的消息摘要,(但会有1x10 ^ 48分之一的机率出现相同的消息摘要,一般使用时忽略)。   SHA-1是一种数据加密算法,该算法的思想是接收一段明文,然后以一种不可逆的方式将它转换成一段(通常更小)密文,也可以简单的理解为取一串输入码(称为预映射或信息),并把它们转化为长度较短、位数固定的输出序列即散列值(也称为信息摘要或信息认证代码)的过程。   单向散列函数的安全性在于其产生散列值的操作过程具有较强的单向性。如果在输入序列中嵌入密码,那么任何人在不知道密码的情况下都不能产生正确的散列值,从而保证了其安全性

手动给内核模块签名

筅森魡賤 提交于 2020-02-05 05:21:15
一、insmod 遇到签名问题: Required key not available key文件路径:out/target/product/msm8953_64/obj/kernel/msm-3.18 sign-file路径:kernel/msm-3.18/scripts 模块路径:out/target/product/msm8953_64/obj/kernel/msm-3.18/driver 举例如下: perl /kernel/msm-3.18/scripts/sign-file sha512 signing_key.priv signing_key.x509 ~/asix.ko 二、开机自动加载模块 diff --git a/qcom/msm8953_64/init.target.rc b/qcom/msm8953_64/init.target.rc index c6caf93..0f14ef9 100755 --- a/qcom/msm8953_64/init.target.rc +++ b/qcom/msm8953_64/init.target.rc @@ -164,6 +164,8 @@ on boot insmod /system/lib/modules/adsprpc.ko # access permission for secure touch chmod

DOJO : How do you reinitiate form elements after ajax call?

空扰寡人 提交于 2020-01-25 09:16:27
问题 I'm trying to do a couple of things using Zend Framework & Dojo Toolkit, and any help would be appreciated. Here's the problem: I have a form that is rendered with the Zend Framework form class, which has an ajax radio button selection. Clicking one of these radio buttons will send an ajax request to another controller, which has no layout, just a rendered form. The ajax request will then populate a div with the new form options. Problem is, when I replace the innerHTML of the div with the

What is the difference writing code in a class and in def __init__(self) in Python? [duplicate]

北城以北 提交于 2020-01-21 18:59:49
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Variables inside and outside of a class __init__() function I understand that when a class is called it will run the code in __init__ before anything. I still don't see the difference between that, and writing the code directly under the class. For example: class main(): x = 1 def disp(self): print self.x class main(): def __init__(self): self.x = 1 def disp(self): print self.x To me, both have the same

SIGKILL init process (PID 1)

两盒软妹~` 提交于 2020-01-21 04:51:09
问题 I'm facing a weird issue regarding sending signal 9 (SIGKILL) to the init process (PID 1). As you may know, SIGKILL can't be ignored via signal handlers. As I tried sending SIGKILL to init, I noticed that nothing was happening; init would not get terminated. Trying to figure out this behaviour, I decided to attach myself to the init process with strace too see more clearly what was happening. Now comes the weird part. If I'm "looking" at the init process with strace and send it SIGKILL, the

Guice call init method after instantinating an object

依然范特西╮ 提交于 2020-01-18 13:36:46
问题 Is it possible to tell Guice to call some method (i.e. init()) after instantinating an object of given type? I look for functionality similar to @PostConstruct annotation in EJB 3. 回答1: Actually, it is possible. You need to define a TypeListener to get the functionality going. Something along the lines of the following in your module definition: bindListener(Matchers.subclassesOf(MyInitClass.class), new TypeListener() { @Override public <I> void hear(final TypeLiteral<I> typeLiteral,

how to initialize an object of subclass with an “existing object of superclass” in objective-C

筅森魡賤 提交于 2020-01-15 14:45:47
问题 I have subclassed NSException class to create CustomException class. Whenever I catch an exception in code (in @catch), i want to initialize an object of CustomException (subclass of NSException) with the object of NSException that is passed as a parameter to @catch. Something like this @catch (NSException * e) { CustomException * ex1=[[CustomException alloc]initWithException:e errorCode:@"-11011" severity:1]; } I tried doing it by passing the NSException object to the init method of

What happens if i call nsobject init more than once? Does it increase retain count?

孤街浪徒 提交于 2020-01-14 10:37:32
问题 I'm pretty new to Objective-C and i have lots of troubles with memory management and still i understand a little. If i have an object, NSArray * myArray for example, and i do this myArray = [[NSArray alloc] initWithObjects:obj1,obj2,obj3,nil]; then i'm doing something and i want myArray to contain new objects and then i init it again [myArray initWithObjects:obj4,obj5,obj6, nil]; seems like it does what i need but is it correct grom the point of view of memory management?does it increase