Microsoft distributes Microsoft SQL Server 2012 fixes in one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security updates that were included with the previous SQL Server 2012 update release.
Symptoms
Assume that you run many xp_cmdshell stored procedures at the same time on multiple sessions in Microsoft SQL Server 2012. In this situation, the first execution of the xp_cmdshell stored procedure is not completed until the last execution is complete.
Cause
This issue occurs because a handle is inherited by the processes that are opened when you run xp_cmdshell stored procedures at the same time.
The CreateProcess API requires handle inheritance to redirect the standard output and error message. If multiple executions of the xp_cmdshell stored procedure run at the same time, newly-opened processes can inherit the handle from existing processes. However, the xp_cmdshell stored procedure waits for the handle to be closed by all the open processes. Therefore, when multiple processes inherit the handle, all xp_cmdshell executions must wait until the handle is closed by the longest-running process.Resolution
To resolve this issue, apply the following cumulative update. This update adds CreateProcess API STARTUPINFOEX options that prevent the handle inheritance for cross process.
Cumulative update information
Cumulative update package 1 for SQL Server 2012 Service Pack 1
The fix for this issue was first released in Cumulative Update 1. For more information about how to obtain this cumulative update package for SQL Server 2012 Service Pack 1, click the following article number to view the article in the Microsoft Knowledge Base:
2765331 Cumulative update package 1 for SQL Server 2012 Service Pack 1Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2012 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2772858 The SQL Server 2012 builds that were released after SQL Server 2012 Service Pack 1 was released
SQL Server 2012
The fix for this issue was first released in Cumulative Update 4. For more information about how to obtain this cumulative update package for SQL Server 2012, click the following article number to view the article in the Microsoft Knowledge Base:
2758687 Cumulative update package 4 for SQL Server 2012Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2012 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2692828 The SQL Server 2012 builds that were released after SQL Server 2012 was released
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
References
For more information about the CreateProcess function, go to the following MSDN website:
General information about the CreateProcess functionFor more information about the xp_cmdshell stored procedure, go to the following MSDN website:
General information about the xp_cmdshell stored procedure For more information about a similar issue, click the following article number to view the article in the Microsoft Knowledge Base:
315939 PRB: Child Inherits Unintended Handles During CreateProcess Call