Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: no atexit support #4221

Closed
gopherbot opened this issue Oct 9, 2012 · 2 comments
Closed

cmd/cgo: no atexit support #4221

gopherbot opened this issue Oct 9, 2012 · 2 comments
Milestone

Comments

@gopherbot
Copy link

by eduard.castany:

What steps will reproduce the problem?
package main

/*
#include <stdio.h>
void print() {
    printf("yuhu\nyuhu");
}
*/
import "C"

func main() {
    C.print()
}

What is the expected output?
yuhu
yuhu

What do you see instead?
yuhu

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
linux 64

Which version are you using?  (run 'go version')
go version devel +2c2052f38c3c Tue Oct 09 09:55:57 2012 +0400
@rsc
Copy link
Contributor

rsc commented Oct 9, 2012

Comment 1:

A Go program exiting does not call C's atexit handlers, so stdout does not get flushed.
If you add C.fflush() to your program, you'll get both lines.
I think we probably want to keep the current behavior: we've worked hard to avoid atexit
handlers.

Labels changed: added priority-later, removed priority-triage.

Status changed to Thinking.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 2:

Yes, please use an explicit C.fflush.

Status changed to WorkingAsIntended.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants