I am using Omniauth in a Rails application for login, my omniauth.rb, is as show below:

```
OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
   provider :facebook, 'xxxxxxx', 'xxxxxxx'
   provider :google_oauth2, 'xxxxxxxxx','xxxxxxxx'
end

```

When a user attempts to login (via Facebook or Goolge) and denies permissions, get the following error:

```
 OmniAuth::Strategies::OAuth2::CallbackError 

```

with this parameters:

```
{"error"=>"access_denied",
 "error_code"=>"200",
 "error_description"=>"Permissions error",
 "error_reason"=>"user_denied",
 "state"=>"60daee5f78d9cc28972050ae8ca8f950bb4ed5958302bcea"}

```

if the user accept, no problem and everything works fine.

I've tried some of the possible solutions related with this error, and listed on this website, but none solved my problem. For example:

[How to rescue OmniAuth::Strategies::OAuth2::CallbackError?](https://stackoverflow.com/questions/10737200/how-to-rescue-omniauthstrategiesoauth2callbackerror)

[Omniauth+facebook error when trying to cancel the popup](https://stackoverflow.com/questions/10647642/omniauthfacebook-error-when-trying-to-cancel-the-popup)

Please, I need help to solve this problem.
['https://Stackoverflow.com/questions/20576864', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3100897/']
Our old friend `strace` solves this mystery.

In the `fflush("cat")` case, awk quickly writes all three values while cat is still loading. When cat finishes loading, it reads all three values in sequence and writes them out at the same time.

In the case of `close("cat")`, awk waits for the process to exit, at which point cat is guaranteed to have read the value, written it, and exited.

I increased the numbers in the `fflush` case from 3 to 1000, and now `awk` reaches 120 before cat catches up, and from there on it works basically as you expect. It prints "1,2,..,120,1,2,...,120,121,121,122,122,123,123,...".

Note that you're not guaranteed to see numbers in perfect pairs. awk blocks until the number has been written to the pipe, but it doesn't wait for cat to do anything with it.
Not really something I have much experience of but the gawk manual tells us:

> 
> fflush([filename])
>  Flush any buffered output associated with filename,
>  which is either a file opened for writing or a shell command for
>  redirecting output **to a pipe** or coprocess.
> 
> 
> 

Note that "cat" as used above is in none of the contexts the gawk manual says are affected by fflush().

The same manual for close() on the other hand says:

> 
> close(filename [, how])
>  Close the file filename for input or output.
>  Alternatively, the argument may be a shell command that was used for
>  creating a coprocess, or for redirecting **to or from a pipe**; then
>  the coprocess or pipe is closed.
> 
> 
> 

Note that the context in which you're using cat is redirecting **from** a pipe and so is included in the list of items affected by close() but not by fflush().