Hi everyone,
I want to set a callback for atexit, but it seems doesn't work.
This is my code.
package main
/*
#include <stdlib.h>
extern void AtExit();
static inline set_atexit() {
atexit(AtExit);
AtExit();
}
*/
import "C"
import (
"fmt"
"io/ioutil"
"time"
)
var n = 0
//export AtExit
func AtExit() {
ioutil.WriteFile(fmt.Sprintf("exit%d", n), []byte("yes, exit
success\n"), 0644)
n++
}
func main() {
C.set_atexit()
fmt.Println("call set_atexit")
}
I get the file 'exit0', but didn't get the file 'exit1'.
Best regards,
Astone
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.