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

Add --quiet option to allow an app to own stdout and stderr #395

wants to merge 2 commits into
base: Cog


None yet
2 participants
Copy link

commented May 4, 2019

I envison to have --quiet and --debugoutput FILENAME as options in the future. For an end-user it is difficult to separate application output/error from VM one (e.g. the infamous thread priority warning).

@zecke zecke force-pushed the zecke:vm-quiet branch from b67fe81 to 83aebb1 May 4, 2019

zecke added some commits May 3, 2019

debug: Prepare to let the app own stderr
The application should own stdout/stderr. This is especially important
when building CLI applications (like pillar, ecstatic, etc) and having
none Smalltalker use them.

Introduce a VM_ERR() function to return a shared FILE* that can be
used for error logging.

For plugins we will need to extend VirtualMachine to carry a pointer
to the VM_ERR method.
@@ -863,13 +863,13 @@ sqInt primitivePluginRequestState(void) { return dpy->primitivePluginRequestSta

static void outOfMemory(void)
/* pushing stderr outputs the error report on stderr instead of stdout */
/* pushing VM_ERR() outputs the error report on VM_ERR() instead of stdout */

This comment has been minimized.

Copy link

bencoman May 15, 2019

What is the significance of changing this comment? (I'm not familiar with pushOutputFile)

pushOutputFile((char *)STDERR_FILENO);
error("out of memory\n");

/* Print an error message, possibly a stack trace, do /not/ exit.
* Allows e.g. writing to a log file and stderr.
* Allows e.g. writing to a log file and VM_ERR().

This comment has been minimized.

Copy link

bencoman May 15, 2019

Same again. Search/replaced within comment useful?


This comment has been minimized.

Copy link

commented May 15, 2019

An expansive scattering of changes, but pretty much all of them are...
simply refactoring fprintf(stderr, ==> fprintf(VM_ERR(),
excepting the following which looks fine...


FILE *VM_ERR(void)
	if (!VM_ERR_FILE) {
		VM_ERR_FILE = stderr;
	return VM_ERR_FILE;

void sqSetVmErrFile(FILE *file)
	VM_ERR_FILE = file;

static int vm_parseArgument(int argc, char **argv)
   else if (!strcmp(argv[0], VMOPTION("quiet"))) {
       sqSetVmErrFile(fopen("/dev/null", "w"));
       return 1;
    return 0; /* option not recognised */

(void) printUsage {
	printf("  "VMOPTION("quiet")"                don't print debugging messages from the VM\n");


And the following seems correct to align with sq.h...

- extern void addIdleUsecs(long idleUsecs);
+ extern void addIdleUsecs(sqInt idleUsecs);

void addIdleUsecs(sqInt);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.