signals

Why does SIGHUP not work on busybox sh in an Alpine Docker container?

孤者浪人 提交于 2020-03-21 06:53:44
问题 Sending SIGHUP with kill -HUP <pid> to a busybox sh process on my native system works as expected and the shell hangs up. However, if I use docker kill to send the signal to a container with docker kill -s HUP <container> it doesn't do anything. The Alpine container is still running: $ CONTAINER=$(docker run -dt alpine:latest) $ docker ps -a --filter "id=$CONTAINER" --format "{{.Status}}" Up 1 second $ docker kill -s HUP $CONTAINER

Django - Unable to delete old file on object change using signals

非 Y 不嫁゛ 提交于 2020-03-03 10:50:29
问题 I have the following signal to delete the old postcover and postcover_tn (thumbnail) from my hard disk. This is working fine if I just delete the files trough my form and call save() but if I want to overwrite the old files with the new ones I upload the old ones are are still on my fs, any idea how to fix this?: signals.py @receiver(models.signals.pre_save, sender=Post) def post_auto_delete_files_on_change(sender, instance, **kwargs): """ Deletes old file from filesystem when corresponding

Django - Unable to delete old file on object change using signals

断了今生、忘了曾经 提交于 2020-03-03 10:48:29
问题 I have the following signal to delete the old postcover and postcover_tn (thumbnail) from my hard disk. This is working fine if I just delete the files trough my form and call save() but if I want to overwrite the old files with the new ones I upload the old ones are are still on my fs, any idea how to fix this?: signals.py @receiver(models.signals.pre_save, sender=Post) def post_auto_delete_files_on_change(sender, instance, **kwargs): """ Deletes old file from filesystem when corresponding

Django学习笔记(8)--- Signals和GenericForeignKey的使用

隐身守侯 提交于 2020-02-29 22:21:34
Signals 顾名思义,就是信号的意思。 Django的signals可以用来干什么呢?比如,论坛中别人给你发了一条消息,自动产生一个消息对象。 我们先来自定义一个信号 Message应用中的models.py from django.db import models from django.contrib.auth.models import User from django.dispatch import Signal notice_signal = Signal(providing_args=['reciver']) #自定义信号 class Message(models.Model): sender = models.ForeignKey(User) content = models.CharField(max_length=50) def newMessage(self,reciver): notice_signel.send(sender=self.__class__,reciver=reciver) #发出信号 Notice应用中的models.py from django.db import models from django.contrib.auth.modesl import User from Message.models import notice

AS3 Signals学习笔记01

╄→гoц情女王★ 提交于 2020-02-29 21:43:33
最近在工作中无意才接触到了as3 signals这个玩意。AS3 Signals是个开源的轻量级框架,这个框架基本可以代替as3中内置的事件这套工作机制。好棒!因为在项目中,使用as3内置事件框架必须通过自定义事件才可以实现值的传递,大量自定义事件、定义常量和整个事件派发的管理、添加侦听器、移除侦听器,或多或少都会带来大量的代码,而signals这个框架思想原来在C#中原本就有,作者整合了C#中的signals思想,实现起来比as3内置的事件更快捷,可以很轻松的实现多个强类型值的传递,的在一定程度上也会简化很多代码。有朋友测试,signals里面用内置的事件竟然是as3内置事件运行速度的4倍。这个我还没测试。 我们知道上图就是as3中的事件流,而在as3中要想派发事件,那派发者必须继承 EventDispatcher或者实现IEventDispatcher接口。在Signals中就派发者就不用这么麻烦了。 Signals: Think Outside the Event Signals:脱离事件思考 signal的中文意思是“信号”,那具体指的是什么呢? 什么是Signal? 一个Signal其本质上是一个微型的针对某个事件的特定的派发者,附带它本身的监听者数组。 一个Signal的基本概念就是,不会使用类似内置事件那种方式、基于字符串的频道,而是化为一个类中具体的event

Starting a process over ssh using bash and then killing it on sigint

北城余情 提交于 2020-02-26 06:31:45
问题 I want to start a couple of jobs on different machines using ssh. If the user then interrupts the main script I want to shut down all the jobs gracefully. Here is a short example of what I'm trying to do: #!/bin/bash trap "aborted" SIGINT SIGTERM aborted() { kill -SIGTERM $bash2_pid exit } ssh -t remote_machine /foo/bar.sh & bash2_pid=$! wait However the bar.sh process is still running the remote machine. If I do the same commands in a terminal window it shuts down the process on the remote

Relationship slow system call with signal

被刻印的时光 ゝ 提交于 2020-02-25 01:42:08
问题 I'm learning slow system call and signals. For the normal system, the slow system call (read from terminal device) can block forever. and below example, it is possible to read to time out after some amount of time. But when I excuted it, The time out does nothing. I can't understand why. Could you explain and show me another example of slow system call? #include <stdio.h> #include <signal.h> #include <unistd.h> static void sig_alrm(int signo){ } int main(){ int n; char line[50]; if(signal

Relationship slow system call with signal

心不动则不痛 提交于 2020-02-25 01:40:53
问题 I'm learning slow system call and signals. For the normal system, the slow system call (read from terminal device) can block forever. and below example, it is possible to read to time out after some amount of time. But when I excuted it, The time out does nothing. I can't understand why. Could you explain and show me another example of slow system call? #include <stdio.h> #include <signal.h> #include <unistd.h> static void sig_alrm(int signo){ } int main(){ int n; char line[50]; if(signal

Relationship slow system call with signal

谁说胖子不能爱 提交于 2020-02-25 01:40:32
问题 I'm learning slow system call and signals. For the normal system, the slow system call (read from terminal device) can block forever. and below example, it is possible to read to time out after some amount of time. But when I excuted it, The time out does nothing. I can't understand why. Could you explain and show me another example of slow system call? #include <stdio.h> #include <signal.h> #include <unistd.h> static void sig_alrm(int signo){ } int main(){ int n; char line[50]; if(signal

How to properly terminate a thread in a signal handler?

别说谁变了你拦得住时间么 提交于 2020-02-16 03:06:15
问题 I want to set up a signal handler for SIGSEGV, SIGILL and possibly a few other signals that, rather than terminating the whole process, just terminates the offending thread and perhaps sets a flag somewhere so that a monitoring thread can complain and start another thread. I'm not sure there is a safe way to do this. Pthreads seems to provide functions for exiting the current thread, as well as canceling another thread, but these potentially call a bunch of at-exit handlers. Even if they don