Error Output To Client
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Output Client Log
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack redirect error output Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Redirect STDOUT and redirect error output windows STDERR to socket in C? up vote 4 down vote favorite 2 I am trying to redirect STDOUT AND STDERR to a socket. I did: if(fork() == 0) { dup2(newsock, STDOUT_FILENO); dup2(newsock, STDERR_FILENO); execvp(); } Somehow, it only showed the first little part
Redirect Error Output To /dev/null
of the output. for example, it showed on "mkdir" when I try to execute ls or mkdir. What's the problem? I tried the flollowing it works, but I can only redirect one of STDOUT or STDERR close(1); dup(newsock); Thanks a lot. c bash shell stdout dup share|improve this question edited Nov 12 '11 at 0:27 asked Nov 11 '11 at 22:36 JJ Liu 45321325 @Dmitri could you please help me on this one? thanks! –JJ Liu Nov 11 '11 at 22:42 add a comment| 3
Redirect Error Output To Stdout
Answers 3 active oldest votes up vote 8 down vote accepted Your use of dup2() looks fine, so the problem is probably elsewhere. The simple program I threw together to test with does not have the issues you are experiencing, so I'll just go over the core of it (around the fork()/execvp() area) with some error checking omitted for brevity: int lsock, /* listening socket */ csock; /* active connection's socket */ pid_t cpid; /* child process ID from fork() */ char *cmd = "somecommand"; char *cmd_args[] = { "somecommand", "firstarg", "secondarg", "howevermanyargs", NULL }; /* note: last item is NULL */ /* ... call socket(), bind(), listen(), etc. ... */ for (;;) { /* loop, accepting connections */ if ( (csock = accept( lsock, NULL, NULL )) == -1) exit(1); cpid = fork(); if (cpid < 0) exit(1); /* exit if fork() fails */ if ( cpid ) { /* In the parent process: */ close( csock ); /* csock is not needed in the parent after the fork */ waitpid( cpid, NULL, 0 ); /* wait for and reap child process */ } else { /* In the child process: */ dup2( csock, STDOUT_FILENO ); /* duplicate socket on stdout */ dup2( csock, STDERR_FILENO ); /* duplicate socket on stderr too */ close( csock ); /* can close the original after it's duplicated */ execvp( cmd, cmd_args ); /* execvp() the command */ } } The above is the core of a very basic server (only one client at a time) that, when it re
Sign in Pricing Blog Support Search GitHub This repository Watch 1,913 Star 35,588 Fork 4,399 meteor/meteor Code Issues 1,003 Pull redirect error output powershell requests 16 Projects 0 Wiki Pulse Graphs New issue Improve error output
Redirect Error Output To File Linux
when using client packages on server #6135 Closed lorensr opened this Issue Feb 1, 2016 · 1 redirect error output to file unix comment Projects None yet Labels Project:Tracker Milestone No milestone Assignees tmeasday 2 participants lorensr commented Feb 1, 2016 When you forget to wrap a Tracker.autorun http://stackoverflow.com/questions/8100817/redirect-stdout-and-stderr-to-socket-in-c in an if Meteor.isClient, it would be nice to get an error saying, "You are using Tracker on the server. Tracker is client-only." Current behavior: Tracker.autorun -> Meteor.users.findOne() results in Error: Can't call yield in a noYieldsAllowed block! related: #1868 tmeasday self-assigned this Feb 2, 2016 tmeasday added pull-requests-encouraged Project:Tracker and removed pull-requests-encouraged labels Feb 2, https://github.com/meteor/meteor/issues/6135 2016 Meteor Development Group member tmeasday commented Feb 2, 2016 Hey @lorensr, this is kind of an unfortunate one. Tracker is only documented to be defined on the client, but it does sort-of-work on the server (in a limited way) -- so I imagine people do rely on the current behavior. I can't really see a way to improve this error without breaking things for those people. If you can see a better way, I think a PR would be a good idea but for now it is what it is I guess. tmeasday closed this Feb 2, 2016 Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About http://serverfault.com/questions/628005/cant-capture-chef-error-to-a-file Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted error output up and rise to the top Can't capture chef error to a file up vote 0 down vote favorite 1 If I run the following: chef-client --force-formatter --logfile STDOUT 2>&1 And then control-c it mid-run (or encounter any sort of error) I see this nice error message: [2014-09-12T00:00:30-04:00] FATAL: SIGINT received, stopping ================================================================================ Recipe Compile Error in /var/cache/chef/cookbooks/users/recipes/fen.rb ================================================================================ SystemExit ---------- exit Cookbook Trace: --------------- /var/cache/chef/cookbooks/users/recipes/default.rb:11:in ``' redirect error output /var/cache/chef/cookbooks/users/recipes/default.rb:11:in `from_file' /var/cache/chef/cookbooks/users/recipes/fen.rb:15:in `from_file' Relevant File Content: ---------------------- /var/cache/chef/cookbooks/users/recipes/default.rb: etc... [2014-09-12T00:00:30-04:00] ERROR: Running exception handlers [2014-09-12T00:00:30-04:00] ERROR: Exception handlers complete [2014-09-12T00:00:30-04:00] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out Chef Client failed. 0 resources updated But if I do the following: chef-client --force-formatter --logfile STDOUT 2>&1 | tee /tmp/chef.log And then control-c, I see all the log messages I was seeing before, with the exception of that nice fatal message telling me what was happening. The file I'm piping too also doesn't show the fatal message. So apparently chef-client is detecting whether or not it's piping to an actual file descriptor, and suppressing output if it is. Does anyone know of a way to stop it from doing this? chef share|improve this question edited Sep 12 '14 at 14:52 asked Sep 12 '14 at 4:04 Mediocre Gopher 338422 Uhm ... why not --logfile /tmp/chef.log? –Gerald Schneider Sep 12 '14 at 8:50 That only logs the fact that there was a fatal to the file, it doesn't log the actual stacktrace I showed above. –Mediocre Gopher Sep 12 '14 at 14:50 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote It seems Chef outputs the