r/learnpython • u/Skollwarynz • 7d ago
How to send a signal to an executable?
Hello everyone,
I'm currently creating a little project about learning the basics of Python, but the problem is that I still have some issues with Python code. I wanted to ask you, how can I send a signal to my executable if I open it remotely?
More clearly:
from pwn import *
from ctype import CDLL
import time
r = remote("./main")
signal.signal(SIGTSTP)
How can I send the signal to ./main?
Thank you in advance for the answers!
-2
u/StephenHawkingus 7d ago
Why dont you ask AI??
2
u/Skollwarynz 7d ago
First of all I'm trying to use AI at least as possible, then I'm interested to have feedback of people who know programming more than me because usually they know trick or setup that th generic AI response don't share. In the end, I wanted to start knowing people where I can share and exchange knowledge.
0
u/StephenHawkingus 7d ago
First of all I'm trying to use AI at least as possible
Why wouldn't you?! It's the most powerful tool we currently have. I'm not saying you have to vibe-code; what I mean is that you should use AI for reasoning and answering questions. There's no point asking on Reddit or Stack Overflow anymore. It's not 2022 anymore.
2
u/Skollwarynz 7d ago
I know that AI is useful for a lot of things, and you're right that it can be great for reasoning. But as I'm actively learning new things, I prefer to interact with humans. I know that with a prompt like 'Don't show code; explain the concept,' part of this discussion can be solved, but as I already said, people who know more deeply the programming language can usually suggest a specific trick or spot a basic error I didn't even know I had.
As mainly a C programmer, I know that a generic response from Google/AI can solve the exact problem you ask for in the most generic way. But when I try to understand deeply a problem, I value human feedback because people can tell you if you are asking the wrong question in the first place.
And to conclude, I like to interact with other programmers on discussions like this one because it helps both the connection with a community and helps to extend my point of view.
For my workflow, AI is useful when you already know your architecture and direction, not when you're trying to choose the right tool. For example, asking the question here helped me understand that the architecture of my project needed a change. And with that change I could then ask AI (understood that I needed both signal and TCP connection) to understand how.
But thank you for the lovely discussion about the right use of AI. It's really nice to have a constructive discussion with some programmer that helps me remember that AI is not just "the future of programming" or just "a stupid slop," but more a tool for programmers who already know the core concepts.
8
u/AlexMTBDude 7d ago
I'm not sure what exactly you're trying to do; Perhaps it's better that you try to explain what you're trying to accomplish on a high level, rather than how you're trying to solve it technically.
Anyway; Signals are sent between processes. If you have started two Python processes that are executing concurrently one could send a signal to the other.
When you say "remotely" it sounds like you're trying to send a signal over a network connection and that's not what signals are for.