0

I'm new to porting but I'd like to give it a shot. I have a library which is built for linux and I want to see if I can make it build on Windows in a day.

A part of the problem seems to be the code:

    ch := make(chan os.Signal, 1)
    signal.Notify(ch, syscall.SIGUSR2)

What would be the simplest way to emulate this process signalling in Windows in Go?

Specifically, I'm looking into what to do with this code https://github.com/influxdata/influxdb/blob/ab87c23be6c630754787dcd9113cd86bd6afaaf1/pkg/lifecycle/resource_debug.go#L30

Could I maybe use https://godoc.org/bitbucket.org/avd/go-ipc/sync#NewEvent for this?

ditoslav
  • 4,563
  • 10
  • 47
  • 79
  • But short answer: there is no direct equivalent, since SIGUSR1 & 2 are, by definition, user-defined signals. So you probably want to think about "What is this Go code doing with the signal, and how can I do the same thing in Windows?" rather than focusing on the signal equivalent (which cannot exist, directly). – Jonathan Hall Dec 30 '20 at 11:23
  • See [this related question](https://stackoverflow.com/q/16429480/13860) for a discussion of some options (but with Python-specific details). – Jonathan Hall Dec 30 '20 at 11:24
  • I'm asking for the closest thing which might emulate this behavior and using the Go libraries. I've not used Go before and I'm hoping someone with experience might speed this up. From reading here I guess something can be done with messages https://stackoverflow.com/questions/140111/sending-an-arbitrary-signal-in-windows – ditoslav Dec 30 '20 at 11:28
  • 2
    I understand what you're asking. And what I'm saying is that you're asking the wrong question. You're focused on the details that cannot be translated. You need to instead focus on the goal of the code. – Jonathan Hall Dec 30 '20 at 11:29
  • 3
    What you're attempting to do is essentially code ["transliteration"](https://en.wikipedia.org/wiki/Transliteration), and your question is analogous to asking "When translating 'I like apples' from English to Spanish, what letter should I use for 'a'?", when in fact that's a nonsense question, since you should not ask about specific letters, but instead about words and phrases. – Jonathan Hall Dec 30 '20 at 11:32
  • From what I understand after doing some reading, had the library developers chosen pipes for IPC or Unix sockets (which are supported on windows now https://bsmadhu.wordpress.com/2018/08/22/unix-domain-socket-support-in-windows/ ) porting this would be way easier – ditoslav Dec 30 '20 at 11:42
  • Yes, that sounds like the right way to go. – Jonathan Hall Dec 30 '20 at 11:46

0 Answers0