从SecureCRT无法执行Ctrl + C开始发散

it2022-05-09  25

问题:

1. 工作电脑windows使用SecureCRT连接开发机,Ctrl + C 无法使用,习惯性使用Ctrl + Z,表面停止输出

2. 每次Ctrl + Z再次执行相同gradlew,就会说已有在进程在运行

解决:

1. SecureCRT Ctrl + C 无法使用: 与复制热键冲突,会话选项中剔除CUA设置中的勾

2.方法1: 使用 Ctrl + C 终止线程

方法2:使用Ctrl + Z后去kill

#查看后台工作,-l选项用于显示PID jobs -l #输出示例 [1]- 10314 Stopped vim ~/.bashrc [2]+ 10833 Stopped find / -print #杀进程,-15为正常结束 kill -15 %1 or kill -15 10833

 

解析1:Ctrl+Z/Ctrl+C的区别(参考:stack)

Ctrl+Z: 发送信号SIGSTOP,用于挂起线程;如上显示的STOPPED状态,可切换到前台fg/切换到后台bg/杀掉kill。

Ctrl+C:发送信号SIGINT,用于杀线程;

说到这里,和理论学习的总算对上了,这就是suspend和kill

解析2:SIGSTOP/SIGINT信号机制

计算机系统层面/Linux层面,都存在线程/进程间通信机制,其中又都包含“信号机制”。

这是一种异步通信机制,某个线程/进程收到信号后对其做出响应。同时也有人将这与硬件层面处理器的中断机制类比。

信号来源:

1. 硬件层:如此处的各种快捷键;

2. 软件来源:系统函数提供信号相关函数,如sigqueue() 信号发送函数;

信号种类:

支持的信号种类都是在国际标准中指定的,逐步扩展。早期设计机制存在丢失信号的可能,被称为“不可靠信号”,之后扩展支持的信号值就对应称为“可靠信号”。

常用的是POSIX信号量规范。

#信号示例 SIGINT #The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interrupt the process SIGKILL #The SIGKILL signal is sent to a process to cause it to terminate immediately (kill) SIGSTOP #The SIGSTOP signal instructs the operating system to stop a process for later resumption.

参考:POSIX signal

信号响应:

进程/线程收到信号后对此做出响应,一般有以下三种。

1. ignore,即不做任何处理,但SIGKILL及SIGSTOP信号是不能忽略的;

2. 执行缺省操作,Linux中定义了不同信号的默认处理动作(wiki中截图部分如下);

3. 捕捉信号,自定义信号处理函数。

SignalPortable numberDefault ActionDescriptionSIGABRT6Terminate (core dump)Process abort signalSIGALRM14TerminateAlarm clockSIGBUSn/aTerminate (core dump)Access to an undefined portion of a memory object.SIGCHLDn/aIgnoreChild process terminated, stopped, or continued.SIGCONTn/aContinueContinue executing, if stopped.SIGFPEn/aTerminate (core dump)Erroneous arithmetic operation.SIGHUP1TerminateHangup.SIGILLn/aTerminate (core dump)Illegal instruction.SIGINT2TerminateTerminal interrupt signal.SIGKILL9TerminateKill (cannot be caught or ignored).SIGPIPEn/aTerminateWrite on a pipe with no one to read it.SIGPOLLn/aTerminatePollable event.SIGPROFn/aTerminateProfiling timer expired.SIGQUIT3Terminate (core dump)Terminal quit signal.SIGSEGVn/aTerminate (core dump)Invalid memory reference.SIGSTOPn/aStopStop executing (cannot be caught or ignored).SIGSYSn/aTerminate (core dump)Bad system call.SIGTERM15TerminateTermination signal.SIGTRAPn/aTerminate (core dump)Trace/breakpoint trap.SIGTSTPn/aStopTerminal stop signal.SIGTTINn/aStopBackground process attempting read.SIGTTOUn/aStopBackground process attempting write.SIGUSR1n/aTerminateUser-defined signal 1.SIGUSR2n/aTerminateUser-defined signal 2.SIGURGn/aIgnoreHigh bandwidth data is available at a socket.SIGVTALRMn/aTerminateVirtual timer expired.SIGXCPUn/aTerminate (core dump)CPU time limit exceeded.SIGXFSZn/aTerminate (core dump)File size limit exceeded

 

参考:http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html

 

转载于:https://www.cnblogs.com/matric/p/6607329.html

相关资源:数据结构—成绩单生成器

最新回复(0)